import { sync as resolve } from 'resolve' ; import { compact } from 'lodash' ; import postCSS from 'postcss' ; import { LoaderFactory } from '../interface' ; const factory = ( { mode , projectSettings } ) => { const { build : { style : { extract } , uses } } = projectSettings ; const plugins = [ uses . includes ( 'tailwind' ) && require ( 'tailwindcss' ) , require ( 'postcss-preset-env' ) ( ) , mode === 'production' ? require ( 'cssnano' ) ( ) : null , ] ; return { loader : resolve ( 'postcss-loader' ) , options : { sourceMap : extract , implementation : postCSS , postcssOptions : { plugins : compact ( plugins ) , } , } , } ; } ; export default factory ;