浏览代码

chore(build) rename option for clarity

factor2
Saúl Ibarra Corretgé 2 年前
父节点
当前提交
e18240cfc6
共有 1 个文件被更改,包括 12 次插入12 次删除
  1. 12
    12
      webpack.config.js

+ 12
- 12
webpack.config.js 查看文件

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

正在加载...
取消
保存