import type { NormalizedConfig } from '@modern-js/core' ; import { Import , applyOptionsChain , logger } from '@modern-js/utils' ; const cloneDeep = Import . lazy ( 'lodash.clonedeep' , require ) ; const merge = Import . lazy ( 'lodash.merge' , require ) ; const checkIfExistNotAllowKeys = ( tailwindConfig ) : [ boolean , string ] => { const notAllowExistKeys = [ 'theme' ] ; let notAllowKey = '' ; const ret = Object . keys ( tailwindConfig ) . some ( key => notAllowExistKeys . includes ( key ) && ( notAllowKey = key ) ) ; return [ ret , notAllowKey ] ; } ; const getPureDesignSystemConfig = ( designSystemConfig ) => { const pureDesignSystemConfig = cloneDeep ( designSystemConfig ) ; delete pureDesignSystemConfig . supportStyledComponents ; return pureDesignSystemConfig ; } ; const getTailwindConfig = ( config , option = { } ) => { const purgeConfig = merge ( { enabled : process . env . NODE_ENV === 'production' , layers : [ 'utilities' ] , content : [ ] , } , option . pureConfig || { } ) ; const defaultTailwindConfig = { purge : purgeConfig , } ; const tailwindConfig = applyOptionsChain ( defaultTailwindConfig , ( config . tools as any ) . tailwindcss || { } ) ; const designSystem = getPureDesignSystemConfig ( ( config . source as any ) . designSystem || { } ) ; const [ exist , key ] = checkIfExistNotAllowKeys ( tailwindConfig ) ; if ( exist ) { logger . error ( `should not exist '${ key }' on tools.tailwindcss, please remove it` ) ; process . exit ( 0 ) ; } tailwindConfig . theme = designSystem || { } ; return tailwindConfig ; } ; export { getTailwindConfig } ;