(cssOptions, preProcessor)
| 106 | |
| 107 | // common function to get style loaders |
| 108 | const getStyleLoaders = (cssOptions, preProcessor) => { |
| 109 | const loaders = [ |
| 110 | isEnvDevelopment && require.resolve("style-loader"), |
| 111 | isEnvProduction && { |
| 112 | loader: MiniCssExtractPlugin.loader, |
| 113 | // css is located in `static/css`, use '../../' to locate index.html folder |
| 114 | // in production `paths.publicUrlOrPath` can be a relative path |
| 115 | options: paths.publicUrlOrPath.startsWith(".") |
| 116 | ? { publicPath: "../../" } |
| 117 | : {}, |
| 118 | }, |
| 119 | { |
| 120 | loader: require.resolve("css-loader"), |
| 121 | options: cssOptions, |
| 122 | }, |
| 123 | { |
| 124 | // Options for PostCSS as we reference these options twice |
| 125 | // Adds vendor prefixing based on your specified browser support in |
| 126 | // package.json |
| 127 | loader: require.resolve("postcss-loader"), |
| 128 | options: { |
| 129 | postcssOptions: { |
| 130 | // Necessary for external CSS imports to work |
| 131 | // https://github.com/facebook/create-react-app/issues/2677 |
| 132 | ident: "postcss", |
| 133 | config: false, |
| 134 | plugins: !useTailwind |
| 135 | ? [ |
| 136 | "postcss-flexbugs-fixes", |
| 137 | [ |
| 138 | "postcss-preset-env", |
| 139 | { |
| 140 | autoprefixer: { |
| 141 | flexbox: "no-2009", |
| 142 | }, |
| 143 | stage: 3, |
| 144 | }, |
| 145 | ], |
| 146 | // Adds PostCSS Normalize as the reset css with default options, |
| 147 | // so that it honors browserslist config in package.json |
| 148 | // which in turn let's users customize the target behavior as per their needs. |
| 149 | "postcss-normalize", |
| 150 | ] |
| 151 | : [ |
| 152 | "tailwindcss", |
| 153 | "postcss-flexbugs-fixes", |
| 154 | [ |
| 155 | "postcss-preset-env", |
| 156 | { |
| 157 | autoprefixer: { |
| 158 | flexbox: "no-2009", |
| 159 | }, |
| 160 | stage: 3, |
| 161 | }, |
| 162 | ], |
| 163 | ], |
| 164 | }, |
| 165 | sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment, |
no test coverage detected