|
@@ -20,15 +20,15 @@ const devServerProxyTarget
|
20
|
20
|
*
|
21
|
21
|
* @param {Object} options - options for the bundles configuration.
|
22
|
22
|
* @param {boolean} options.analyzeBundle - whether the bundle needs to be analyzed for size.
|
23
|
|
- * @param {boolean} options.minimize - whether the code should be minimized or not.
|
|
23
|
+ * @param {boolean} options.isProduction - whether this is a production build or not.
|
24
|
24
|
* @param {number} size - the size limit to apply.
|
25
|
25
|
* @returns {Object} a performance hints object.
|
26
|
26
|
*/
|
27
|
27
|
function getPerformanceHints(options, size) {
|
28
|
|
- const { analyzeBundle, minimize } = options;
|
|
28
|
+ const { analyzeBundle, isProduction } = options;
|
29
|
29
|
|
30
|
30
|
return {
|
31
|
|
- hints: minimize && !analyzeBundle ? 'error' : false,
|
|
31
|
+ hints: isProduction && !analyzeBundle ? 'error' : false,
|
32
|
32
|
maxAssetSize: size,
|
33
|
33
|
maxEntrypointSize: size
|
34
|
34
|
};
|
|
@@ -90,15 +90,15 @@ function devServerProxyBypass({ path }) {
|
90
|
90
|
*
|
91
|
91
|
* @param {Object} options - options for the bundles configuration.
|
92
|
92
|
* @param {boolean} options.detectCircularDeps - whether to detect circular dependencies or not.
|
93
|
|
- * @param {boolean} options.minimize - whether the code should be minimized or not.
|
|
93
|
+ * @param {boolean} options.isProduction - whether this is a production build or not.
|
94
|
94
|
* @returns {Object} the base config object.
|
95
|
95
|
*/
|
96
|
96
|
function getConfig(options = {}) {
|
97
|
|
- const { detectCircularDeps, minimize } = options;
|
|
97
|
+ const { detectCircularDeps, isProduction } = options;
|
98
|
98
|
|
99
|
99
|
return {
|
100
|
|
- devtool: minimize ? 'source-map' : 'eval-source-map',
|
101
|
|
- mode: minimize ? 'production' : 'development',
|
|
100
|
+ devtool: isProduction ? 'source-map' : 'eval-source-map',
|
|
101
|
+ mode: isProduction ? 'production' : 'development',
|
102
|
102
|
module: {
|
103
|
103
|
rules: [ {
|
104
|
104
|
// Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React
|
|
@@ -186,11 +186,11 @@ function getConfig(options = {}) {
|
186
|
186
|
__filename: true
|
187
|
187
|
},
|
188
|
188
|
optimization: {
|
189
|
|
- concatenateModules: minimize,
|
190
|
|
- minimize
|
|
189
|
+ concatenateModules: isProduction,
|
|
190
|
+ minimize: isProduction
|
191
|
191
|
},
|
192
|
192
|
output: {
|
193
|
|
- filename: `[name]${minimize ? '.min' : ''}.js`,
|
|
193
|
+ filename: `[name]${isProduction ? '.min' : ''}.js`,
|
194
|
194
|
path: `${__dirname}/build`,
|
195
|
195
|
publicPath: '/libs/',
|
196
|
196
|
sourceMapFilename: '[file].map'
|
|
@@ -274,12 +274,12 @@ module.exports = (_env, argv) => {
|
274
|
274
|
const isProduction = mode === 'production';
|
275
|
275
|
const configOptions = {
|
276
|
276
|
detectCircularDeps: Boolean(process.env.DETECT_CIRCULAR_DEPS),
|
277
|
|
- minimize: isProduction
|
|
277
|
+ isProduction
|
278
|
278
|
};
|
279
|
279
|
const config = getConfig(configOptions);
|
280
|
280
|
const perfHintOptions = {
|
281
|
281
|
analyzeBundle,
|
282
|
|
- minimize: isProduction
|
|
282
|
+ isProduction
|
283
|
283
|
};
|
284
|
284
|
|
285
|
285
|
return [
|