1
1
const paths = require ( './paths' )
2
2
const packageJson = require ( '../package' )
3
3
4
- const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' )
5
-
6
- const postcssNormalize = require ( 'postcss-normalize' )
7
- const getCSSModuleLocalIdent = require ( 'react-dev-utils/getCSSModuleLocalIdent' )
8
-
9
4
const dependencies = Object . keys ( packageJson . dependencies )
10
5
const devDependencies = Object . keys ( packageJson . devDependencies )
11
6
const externals = [
@@ -14,72 +9,6 @@ const externals = [
14
9
/ .* m a t e r i a l - u i .* / ,
15
10
]
16
11
17
- // style files regexes
18
- const cssRegex = / \. c s s $ /
19
- const cssModuleRegex = / \. m o d u l e \. c s s $ /
20
- const sassRegex = / \. ( s c s s | s a s s ) $ /
21
- const sassModuleRegex = / \. m o d u l e \. ( s c s s | s a s s ) $ /
22
-
23
- const isEnvProduction = true
24
- const isEnvDevelopment = false
25
- const shouldUseSourceMap = process . env . GENERATE_SOURCEMAP !== 'false'
26
-
27
- const getStyleLoaders = ( cssOptions , preProcessor ) => {
28
- const loaders = [
29
- isEnvDevelopment && require . resolve ( 'style-loader' ) ,
30
- isEnvProduction && {
31
- loader : MiniCssExtractPlugin . loader ,
32
- options : { } ,
33
- } ,
34
- {
35
- loader : require . resolve ( 'css-loader' ) ,
36
- options : cssOptions ,
37
- } ,
38
- {
39
- // Options for PostCSS as we reference these options twice
40
- // Adds vendor prefixing based on your specified browser support in
41
- // package.json
42
- loader : require . resolve ( 'postcss-loader' ) ,
43
- options : {
44
- // Necessary for external CSS imports to work
45
- // https://github.com/facebook/create-react-app/issues/2677
46
- ident : 'postcss' ,
47
- plugins : ( ) => [
48
- require ( 'postcss-flexbugs-fixes' ) ,
49
- require ( 'postcss-preset-env' ) ( {
50
- autoprefixer : {
51
- flexbox : 'no-2009' ,
52
- } ,
53
- stage : 3 ,
54
- } ) ,
55
- // Adds PostCSS Normalize as the reset css with default options,
56
- // so that it honors browserslist config in package.json
57
- // which in turn let's users customize the target behavior as per their needs.
58
- postcssNormalize ( ) ,
59
- ] ,
60
- sourceMap : isEnvProduction && shouldUseSourceMap ,
61
- } ,
62
- } ,
63
- ] . filter ( Boolean )
64
- if ( preProcessor ) {
65
- loaders . push (
66
- {
67
- loader : require . resolve ( 'resolve-url-loader' ) ,
68
- options : {
69
- sourceMap : isEnvProduction && shouldUseSourceMap ,
70
- } ,
71
- } ,
72
- {
73
- loader : require . resolve ( preProcessor ) ,
74
- options : {
75
- sourceMap : true ,
76
- } ,
77
- }
78
- )
79
- }
80
- return loaders
81
- }
82
-
83
12
module . exports = {
84
13
mode : 'production' ,
85
14
entry : paths . appIndexJs ,
@@ -90,7 +19,7 @@ module.exports = {
90
19
} ,
91
20
externals : externals ,
92
21
optimization : {
93
- minimize : false
22
+ minimize : true ,
94
23
} ,
95
24
module : {
96
25
strictExportPresence : true ,
@@ -150,96 +79,9 @@ module.exports = {
150
79
// See #6846 for context on why cacheCompression is disabled
151
80
cacheCompression : false ,
152
81
153
- // TODO
154
- // compact: true,
82
+ compact : true ,
155
83
} ,
156
84
} ,
157
-
158
- // {
159
- // test: cssRegex,
160
- // exclude: cssModuleRegex,
161
- // use: getStyleLoaders({
162
- // importLoaders: 1,
163
- // sourceMap: isEnvProduction && shouldUseSourceMap,
164
- // }),
165
- // // Don't consider CSS imports dead code even if the
166
- // // containing package claims to have no side effects.
167
- // // Remove this when webpack adds a warning or an error for this.
168
- // // See https://github.com/webpack/webpack/issues/6571
169
- // sideEffects: true,
170
- // },
171
- // // Adds support for CSS Modules (https://github.com/css-modules/css-modules)
172
- // // using the extension .module.css
173
- // {
174
- // test: cssModuleRegex,
175
- // use: getStyleLoaders({
176
- // importLoaders: 1,
177
- // sourceMap: isEnvProduction && shouldUseSourceMap,
178
- // modules: true,
179
- // getLocalIdent: getCSSModuleLocalIdent,
180
- // }),
181
- // },
182
- // // Opt-in support for SASS (using .scss or .sass extensions).
183
- // // By default we support SASS Modules with the
184
- // // extensions .module.scss or .module.sass
185
- // {
186
- // test: sassRegex,
187
- // exclude: sassModuleRegex,
188
- // use: getStyleLoaders(
189
- // {
190
- // importLoaders: 2,
191
- // sourceMap: isEnvProduction && shouldUseSourceMap,
192
- // },
193
- // 'sass-loader'
194
- // ),
195
- // // Don't consider CSS imports dead code even if the
196
- // // containing package claims to have no side effects.
197
- // // Remove this when webpack adds a warning or an error for this.
198
- // // See https://github.com/webpack/webpack/issues/6571
199
- // sideEffects: true,
200
- // },
201
- // // Adds support for CSS Modules, but using SASS
202
- // // using the extension .module.scss or .module.sass
203
- // {
204
- // test: sassModuleRegex,
205
- // use: getStyleLoaders(
206
- // {
207
- // importLoaders: 2,
208
- // sourceMap: isEnvProduction && shouldUseSourceMap,
209
- // modules: true,
210
- // getLocalIdent: getCSSModuleLocalIdent,
211
- // },
212
- // 'sass-loader'
213
- // ),
214
- // },
215
-
216
- // Process any JS outside of the app with Babel.
217
- // Unlike the application JS, we only compile the standard ES features.
218
- // {
219
- // test: /\.(js|mjs)$/,
220
- // exclude: /@babel (?:\/|\\{1,2})runtime/,
221
- // loader: require.resolve('babel-loader'),
222
- // options: {
223
- // babelrc: false,
224
- // configFile: false,
225
- // compact: false,
226
- // presets: [
227
- // [
228
- // require.resolve('babel-preset-react-app/dependencies'),
229
- // {helpers: true},
230
- // ],
231
- // ],
232
- // cacheDirectory: true,
233
- // // See #6846 for context on why cacheCompression is disabled
234
- // cacheCompression: false,
235
- //
236
- // // If an error happens in a package, it's possible to be
237
- // // because it was compiled. Thus, we don't want the browser
238
- // // debugger to show the original code. Instead, the code
239
- // // being evaluated would be much more helpful.
240
- // sourceMaps: false,
241
- // },
242
- // },
243
85
] ,
244
86
} ,
245
87
] ,
0 commit comments