@qse/edu-scripts 1.13.7 → 1.13.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,95 +1,91 @@
1
- "use strict";
2
-
3
- const fs = require('fs');
4
- const webpack = require('webpack');
5
- const HtmlWebpackPlugin = require('html-webpack-plugin');
6
- const {
7
- BundleAnalyzerPlugin
8
- } = require('webpack-bundle-analyzer');
9
- const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
10
- const paths = require('./paths');
11
- const TerserPlugin = require('terser-webpack-plugin');
12
- const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
13
- const appPkg = require(paths.package);
14
- const appConfig = require('../utils/appConfig');
15
- const {
16
- ESBuildMinifyPlugin
17
- } = require('esbuild-loader');
18
- const jsMainPath = appConfig.grayscale ? `${appPkg.name}/beta/${appPkg.name}` : `${appPkg.name}/${appPkg.name}`;
19
- const assetPath = appConfig.grayscale ? `${appPkg.name}/beta/${appPkg.version}` : `${appPkg.name}/${appPkg.version}`;
20
- const cssRegex = /\.css$/;
21
- const cssModuleRegex = /\.module\.css$/;
22
- const lessRegex = /\.less$/;
23
- const lessModuleRegex = /\.module\.less$/;
24
- const imageInlineSizeLimit = 10 * 1024;
25
- const qseCDN = (() => {
26
- const contents = paths.indexHTML.map(url => fs.readFileSync(url, 'utf-8'));
1
+ // src/config/webpackConfig.js
2
+ var fs = require("fs");
3
+ var webpack = require("webpack");
4
+ var HtmlWebpackPlugin = require("html-webpack-plugin");
5
+ var { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
6
+ var ReactRefreshPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
7
+ var paths = require("./paths");
8
+ var TerserPlugin = require("terser-webpack-plugin");
9
+ var CaseSensitivePathsPlugin = require("case-sensitive-paths-webpack-plugin");
10
+ var appPkg = require(paths.package);
11
+ var appConfig = require("../utils/appConfig");
12
+ var { ESBuildMinifyPlugin } = require("esbuild-loader");
13
+ var jsMainPath = appConfig.grayscale ? `${appPkg.name}/beta/${appPkg.name}` : `${appPkg.name}/${appPkg.name}`;
14
+ var assetPath = appConfig.grayscale ? `${appPkg.name}/beta/${appPkg.version}` : `${appPkg.name}/${appPkg.version}`;
15
+ var cssRegex = /\.css$/;
16
+ var cssModuleRegex = /\.module\.css$/;
17
+ var lessRegex = /\.less$/;
18
+ var lessModuleRegex = /\.module\.less$/;
19
+ var imageInlineSizeLimit = 10 * 1024;
20
+ var qseCDN = (() => {
21
+ const contents = paths.indexHTML.map((url) => fs.readFileSync(url, "utf-8"));
27
22
  function include(pattern) {
28
23
  const regexp = new RegExp(pattern);
29
- return contents.some(content => regexp.test(content));
24
+ return contents.some((content) => regexp.test(content));
30
25
  }
31
26
  return {
32
27
  isUseCommon: include(/react16.14.*_common31?.js|react-dev-preset.js/),
33
28
  isUseAxios: include(/react16.14.*_axios0.21.1|react-dev-preset.js/),
34
- isUseMoment: include('moment2.29.1.js'),
35
- isUseAntd: include('antd3.26.20.js'),
36
- isUseQsbAntd: include('qsb-antd.min.js'),
37
- isUseQsbSchemeRender: include('qsb-scheme-render.min.js')
29
+ isUseMoment: include("moment2.29.1.js"),
30
+ isUseAntd: include("antd3.26.20.js"),
31
+ isUseQsbAntd: include("qsb-antd.min.js"),
32
+ isUseQsbSchemeRender: include("qsb-scheme-render.min.js")
38
33
  };
39
34
  })();
40
-
41
- /**
42
- * @param {*} args
43
- * @param {import('../utils/defineConfig').Config} override
44
- */
45
35
  module.exports = function getWebpackConfig(args, override) {
46
- var _override$pure_funcs, _override$pure_funcs2;
47
- const isDev = process.env.NODE_ENV === 'development';
48
- const isProd = process.env.NODE_ENV === 'production';
49
-
50
- // common function to get style loaders
36
+ const isDev = process.env.NODE_ENV === "development";
37
+ const isProd = process.env.NODE_ENV === "production";
51
38
  const getStyleLoaders = (cssOptions, preProcessor) => {
52
- const loaders = [{
53
- loader: 'style-loader',
54
- options: {
55
- attributes: {
56
- 'data-module': appPkg.name,
57
- 'data-version': appPkg.version
39
+ const loaders = [
40
+ {
41
+ loader: "style-loader",
42
+ options: { attributes: { "data-module": appPkg.name, "data-version": appPkg.version } }
43
+ },
44
+ {
45
+ loader: "css-loader",
46
+ options: cssOptions
47
+ },
48
+ {
49
+ // Options for PostCSS as we reference these options twice
50
+ // Adds vendor prefixing based on your specified browser support in
51
+ // package.json
52
+ loader: "postcss-loader",
53
+ options: {
54
+ postcssOptions: {
55
+ // Necessary for external CSS imports to work
56
+ // https://github.com/facebook/create-react-app/issues/2677
57
+ ident: "postcss",
58
+ config: false,
59
+ plugins: [
60
+ isProd && require("cssnano")({ preset: "default" }),
61
+ fs.existsSync(paths.tailwind) && "tailwindcss",
62
+ "postcss-flexbugs-fixes",
63
+ [
64
+ "postcss-preset-env",
65
+ {
66
+ autoprefixer: {
67
+ flexbox: "no-2009"
68
+ }
69
+ // https://preset-env.cssdb.org/features/#stage-2
70
+ }
71
+ ],
72
+ isProd && require("./plugins/postcss-safe-area")(),
73
+ isProd && ["postcss-momentum-scrolling", ["scroll", "auto"]],
74
+ "postcss-normalize",
75
+ ...override.extraPostCSSPlugins
76
+ ].filter(Boolean)
77
+ },
78
+ sourceMap: isDev
58
79
  }
59
80
  }
60
- }, {
61
- loader: 'css-loader',
62
- options: cssOptions
63
- }, {
64
- // Options for PostCSS as we reference these options twice
65
- // Adds vendor prefixing based on your specified browser support in
66
- // package.json
67
- loader: 'postcss-loader',
68
- options: {
69
- postcssOptions: {
70
- // Necessary for external CSS imports to work
71
- // https://github.com/facebook/create-react-app/issues/2677
72
- ident: 'postcss',
73
- config: false,
74
- plugins: [isProd && require('cssnano')({
75
- preset: 'default'
76
- }), fs.existsSync(paths.tailwind) && 'tailwindcss', 'postcss-flexbugs-fixes', ['postcss-preset-env', {
77
- autoprefixer: {
78
- flexbox: 'no-2009'
79
- }
80
- // https://preset-env.cssdb.org/features/#stage-2
81
- }], isProd && require('./plugins/postcss-safe-area')(), isProd && ['postcss-momentum-scrolling', ['scroll', 'auto']], 'postcss-normalize', ...override.extraPostCSSPlugins].filter(Boolean)
82
- },
83
- sourceMap: isDev
84
- }
85
- }];
86
- if (preProcessor === 'less-loader') {
81
+ ];
82
+ if (preProcessor === "less-loader") {
87
83
  loaders.push({
88
- loader: 'less-loader',
84
+ loader: "less-loader",
89
85
  options: {
90
86
  lessOptions: {
91
87
  javascriptEnabled: true,
92
- modifyVars: fs.existsSync(paths.theme) ? require(paths.theme) : undefined
88
+ modifyVars: fs.existsSync(paths.theme) ? require(paths.theme) : void 0
93
89
  },
94
90
  sourceMap: true
95
91
  }
@@ -97,281 +93,320 @@ module.exports = function getWebpackConfig(args, override) {
97
93
  }
98
94
  return loaders;
99
95
  };
100
-
101
- /** @type {webpack.Configuration} */
102
96
  const config = {
103
97
  context: process.cwd(),
104
98
  mode: process.env.NODE_ENV,
105
- entry: './src/index',
106
- target: 'browserslist',
99
+ entry: "./src/index",
100
+ target: "browserslist",
107
101
  output: {
108
102
  filename: appConfig.single ? `js/${jsMainPath}_${appPkg.version}.[contenthash:6].js` : `js/${jsMainPath}_${appPkg.version}.js`,
109
103
  chunkFilename: `js/${assetPath}/[name].[chunkhash:8].js`,
110
104
  assetModuleFilename: `images/${assetPath}/[name].[hash:6][ext]`,
111
105
  uniqueName: appPkg.name,
112
- publicPath: ''
106
+ publicPath: ""
113
107
  },
114
- externals: Object.assign({}, qseCDN.isUseCommon && {
115
- react: 'React',
116
- 'react-dom': 'ReactDOM',
117
- 'natty-fetch': 'nattyFetch',
118
- 'natty-storage': 'nattyStorage',
119
- 'common-utils': 'CommonUtils',
120
- '@qse/common-utils': 'CommonUtils'
121
- }, qseCDN.isUseAxios && {
122
- axios: 'axios'
123
- }, qseCDN.isUseMoment && {
124
- moment: 'moment'
125
- }, qseCDN.isUseAntd && Object.assign({
126
- react: 'React',
127
- 'react-dom': 'ReactDOM',
128
- moment: 'moment',
129
- antd: 'antd'
130
- }, qseCDN.isUseQsbAntd && {
131
- '@qse/antd': 'qsbAntd',
132
- '@qsb/antd': 'qsbAntd'
133
- }, qseCDN.isUseQsbSchemeRender && {
134
- '@qse/scheme-render': 'qsbSchemeRender',
135
- '@qsb/scheme-render': 'qsbSchemeRender'
136
- }),
137
- // 教育工程这些一定都需要 external
138
- !appConfig.single && Object.assign({
139
- react: 'React',
140
- 'react-dom': 'ReactDOM',
141
- 'natty-fetch': 'nattyFetch',
142
- 'natty-storage': 'nattyStorage',
143
- 'common-utils': 'CommonUtils',
144
- '@qse/common-utils': 'CommonUtils',
145
- moment: 'moment',
146
- antd: 'antd'
147
- }, isProd && {
148
- '@qse/antd': 'qsbAntd',
149
- '@qsb/antd': 'qsbAntd',
150
- '@qse/scheme-render': 'qsbSchemeRender',
151
- '@qsb/scheme-render': 'qsbSchemeRender'
152
- }), override.externals),
108
+ externals: Object.assign(
109
+ {},
110
+ qseCDN.isUseCommon && {
111
+ react: "React",
112
+ "react-dom": "ReactDOM",
113
+ "natty-fetch": "nattyFetch",
114
+ "natty-storage": "nattyStorage",
115
+ "common-utils": "CommonUtils",
116
+ "@qse/common-utils": "CommonUtils"
117
+ },
118
+ qseCDN.isUseAxios && { axios: "axios" },
119
+ qseCDN.isUseMoment && { moment: "moment" },
120
+ qseCDN.isUseAntd && Object.assign(
121
+ {
122
+ react: "React",
123
+ "react-dom": "ReactDOM",
124
+ moment: "moment",
125
+ antd: "antd"
126
+ },
127
+ qseCDN.isUseQsbAntd && {
128
+ "@qse/antd": "qsbAntd",
129
+ "@qsb/antd": "qsbAntd"
130
+ },
131
+ qseCDN.isUseQsbSchemeRender && {
132
+ "@qse/scheme-render": "qsbSchemeRender",
133
+ "@qsb/scheme-render": "qsbSchemeRender"
134
+ }
135
+ ),
136
+ // 教育工程这些一定都需要 external
137
+ !appConfig.single && Object.assign(
138
+ {
139
+ react: "React",
140
+ "react-dom": "ReactDOM",
141
+ "natty-fetch": "nattyFetch",
142
+ "natty-storage": "nattyStorage",
143
+ "common-utils": "CommonUtils",
144
+ "@qse/common-utils": "CommonUtils",
145
+ moment: "moment",
146
+ antd: "antd"
147
+ },
148
+ isProd && {
149
+ "@qse/antd": "qsbAntd",
150
+ "@qsb/antd": "qsbAntd",
151
+ "@qse/scheme-render": "qsbSchemeRender",
152
+ "@qsb/scheme-render": "qsbSchemeRender"
153
+ }
154
+ ),
155
+ override.externals
156
+ ),
153
157
  resolve: {
154
158
  alias: {
155
- '@': paths.src,
159
+ "@": paths.src,
156
160
  ...override.alias
157
161
  },
158
- extensions: ['.web.js', '.web.mjs', '.js', '.mjs', '.jsx', '.ts', '.tsx', '.json', '.wasm']
162
+ extensions: [".web.js", ".web.mjs", ".js", ".mjs", ".jsx", ".ts", ".tsx", ".json", ".wasm"]
159
163
  },
160
- stats: isDev ? {
161
- preset: 'errors-warnings',
162
- timings: true
163
- } : undefined,
164
- devtool: isDev ? 'cheap-module-source-map' : false,
164
+ stats: isDev ? { preset: "errors-warnings", timings: true } : void 0,
165
+ devtool: isDev ? "cheap-module-source-map" : false,
165
166
  cache: {
166
- type: 'filesystem',
167
- version: require('../../package.json').version,
167
+ type: "filesystem",
168
+ version: require("../../package.json").version,
168
169
  buildDependencies: {
169
170
  config: [__filename],
170
- override: [paths.override].filter(f => fs.existsSync(f)),
171
- tsconfig: [paths.tsconfig, paths.jsconfig].filter(f => fs.existsSync(f))
171
+ override: [paths.override].filter((f) => fs.existsSync(f)),
172
+ tsconfig: [paths.tsconfig, paths.jsconfig].filter((f) => fs.existsSync(f))
172
173
  }
173
174
  },
174
175
  module: {
175
- parser: {
176
- javascript: {
177
- exportsPresence: 'error'
178
- }
179
- },
180
- rules: [{
181
- oneOf: [
182
- // 两个 babel-loader 是为了处理 pdfjs-dist 与 ofd.js
176
+ parser: { javascript: { exportsPresence: "error" } },
177
+ rules: [
183
178
  {
184
- test: /\.(j|t)sx?$/,
185
- loader: 'babel-loader',
186
- include: paths.src,
187
- options: require('./babel')()
188
- }, (override.transformNodeModules || isProd) && {
189
- test: /\.m?js$/,
190
- loader: 'babel-loader',
191
- exclude: /@babel(?:\/|\\{1,2})runtime/,
192
- options: require('./babel.dependencies')()
193
- }, {
194
- test: cssRegex,
195
- exclude: cssModuleRegex,
196
- use: getStyleLoaders({
197
- importLoaders: 1,
198
- sourceMap: isDev,
199
- modules: {
200
- mode: 'global',
201
- localIdentName: '[local]--[hash:base64:6]'
202
- }
203
- }),
204
- sideEffects: true
205
- }, {
206
- test: cssModuleRegex,
207
- use: getStyleLoaders({
208
- importLoaders: 1,
209
- sourceMap: isDev,
210
- modules: {
211
- mode: 'local',
212
- localIdentName: '[local]--[hash:base64:6]'
213
- }
214
- })
215
- }, {
216
- test: lessRegex,
217
- exclude: lessModuleRegex,
218
- use: getStyleLoaders({
219
- importLoaders: 2,
220
- sourceMap: isDev,
221
- modules: {
222
- mode: 'global',
223
- localIdentName: '[local]--[hash:base64:6]'
224
- }
225
- }, 'less-loader'),
226
- sideEffects: true
227
- }, {
228
- test: lessModuleRegex,
229
- use: getStyleLoaders({
230
- importLoaders: 2,
231
- sourceMap: isDev,
232
- modules: {
233
- mode: 'local',
234
- localIdentName: '[local]--[hash:base64:6]'
235
- }
236
- }, 'less-loader')
237
- }, {
238
- test: /\.(bmp|png|jpe?g|gif|webp)$/,
239
- type: 'asset',
240
- parser: {
241
- dataUrlCondition: {
242
- maxSize: imageInlineSizeLimit // 10kb
243
- }
244
- }
245
- }, {
246
- test: /\.svg$/,
247
- type: 'asset',
248
- parser: {
249
- dataUrlCondition: {
250
- maxSize: imageInlineSizeLimit // 10kb
251
- }
252
- },
253
-
254
- issuer: {
255
- and: [/\.(css|less)$/]
256
- }
257
- }, {
258
- test: /\.svg$/,
259
- use: [{
260
- loader: '@svgr/webpack',
261
- options: {
262
- prettier: false,
263
- svgo: false,
264
- svgoConfig: {
265
- plugins: [{
266
- removeViewBox: false
267
- }]
179
+ oneOf: [
180
+ {
181
+ resourceQuery: /raw/,
182
+ type: "asset/source"
183
+ },
184
+ {
185
+ test: /\.(j|t)sx?$/,
186
+ loader: "babel-loader",
187
+ exclude: /node_modules/,
188
+ options: require("./babel")()
189
+ },
190
+ (override.transformNodeModules || isProd) && {
191
+ test: /\.m?js$/,
192
+ loader: "babel-loader",
193
+ exclude: /@babel(?:\/|\\{1,2})runtime/,
194
+ options: require("./babel.dependencies")()
195
+ },
196
+ {
197
+ test: cssRegex,
198
+ exclude: cssModuleRegex,
199
+ use: getStyleLoaders({
200
+ importLoaders: 1,
201
+ sourceMap: isDev,
202
+ modules: {
203
+ mode: "global",
204
+ localIdentName: "[local]--[hash:base64:6]"
205
+ }
206
+ }),
207
+ sideEffects: true
208
+ },
209
+ {
210
+ test: cssModuleRegex,
211
+ use: getStyleLoaders({
212
+ importLoaders: 1,
213
+ sourceMap: isDev,
214
+ modules: {
215
+ mode: "local",
216
+ localIdentName: "[local]--[hash:base64:6]"
217
+ }
218
+ })
219
+ },
220
+ {
221
+ test: lessRegex,
222
+ exclude: lessModuleRegex,
223
+ use: getStyleLoaders(
224
+ {
225
+ importLoaders: 2,
226
+ sourceMap: isDev,
227
+ modules: {
228
+ mode: "global",
229
+ localIdentName: "[local]--[hash:base64:6]"
230
+ }
231
+ },
232
+ "less-loader"
233
+ ),
234
+ sideEffects: true
235
+ },
236
+ {
237
+ test: lessModuleRegex,
238
+ use: getStyleLoaders(
239
+ {
240
+ importLoaders: 2,
241
+ sourceMap: isDev,
242
+ modules: {
243
+ mode: "local",
244
+ localIdentName: "[local]--[hash:base64:6]"
245
+ }
246
+ },
247
+ "less-loader"
248
+ )
249
+ },
250
+ {
251
+ test: /\.(bmp|png|jpe?g|gif|webp)$/,
252
+ type: "asset",
253
+ parser: {
254
+ dataUrlCondition: {
255
+ maxSize: imageInlineSizeLimit
256
+ // 10kb
257
+ }
258
+ }
259
+ },
260
+ {
261
+ test: /\.svg$/,
262
+ type: "asset",
263
+ parser: {
264
+ dataUrlCondition: {
265
+ maxSize: imageInlineSizeLimit
266
+ // 10kb
267
+ }
268
268
  },
269
- titleProp: true,
270
- ref: false
271
- }
272
- }, {
273
- loader: 'url-loader',
274
- options: {
275
- limit: imageInlineSizeLimit
269
+ issuer: {
270
+ and: [/\.(css|less)$/]
271
+ }
272
+ },
273
+ {
274
+ test: /\.svg$/,
275
+ use: [
276
+ {
277
+ loader: "@svgr/webpack",
278
+ options: {
279
+ prettier: false,
280
+ svgo: false,
281
+ svgoConfig: {
282
+ plugins: [{ removeViewBox: false }]
283
+ },
284
+ titleProp: true,
285
+ ref: false
286
+ }
287
+ },
288
+ {
289
+ loader: "url-loader",
290
+ options: {
291
+ limit: imageInlineSizeLimit
292
+ }
293
+ }
294
+ ],
295
+ issuer: {
296
+ and: [/\.(ts|tsx|js|jsx|md|mdx)$/]
297
+ }
298
+ },
299
+ {
300
+ test: /\.md$/,
301
+ type: "asset/source"
302
+ },
303
+ {
304
+ // Exclude `js` files to keep "css" loader working as it injects
305
+ // its runtime that would otherwise be processed through "file" loader.
306
+ // Also exclude `html` and `json` extensions so they get processed
307
+ // by webpacks internal loaders.
308
+ exclude: [/^$/, /\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
309
+ type: "asset/resource"
276
310
  }
277
- }],
278
- issuer: {
279
- and: [/\.(ts|tsx|js|jsx|md|mdx)$/]
280
- }
281
- }, {
282
- // Exclude `js` files to keep "css" loader working as it injects
283
- // its runtime that would otherwise be processed through "file" loader.
284
- // Also exclude `html` and `json` extensions so they get processed
285
- // by webpacks internal loaders.
286
- exclude: [/^$/, /\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
287
- type: 'asset/resource'
288
- }].filter(Boolean)
289
- }]
311
+ ].filter(Boolean)
312
+ }
313
+ ]
290
314
  },
291
- plugins: [qseCDN.isUseCommon && new webpack.DllReferencePlugin({
292
- manifest: require('../asset/dll/libcommon3-manifest.json')
293
- }), new webpack.IgnorePlugin({
294
- resourceRegExp: /^\.\/locale$/,
295
- contextRegExp: /moment$/
296
- }), new webpack.DefinePlugin({
297
- 'process.env.APP_NAME': JSON.stringify(appPkg.name),
298
- 'process.env.APP_VERSION': JSON.stringify(appPkg.version),
299
- 'process.env.BABEL_ENV': JSON.stringify(process.env.BABEL_ENV),
300
- 'process.env.BROWSERSLIST': JSON.stringify(process.env.BROWSERSLIST),
301
- 'process.env.WDS_SOCKET_HOST': JSON.stringify(process.env.WDS_SOCKET_HOST),
302
- 'process.env.WDS_SOCKET_PORT': JSON.stringify(process.env.WDS_SOCKET_PORT),
303
- ...override.define
304
- }), new webpack.ProgressPlugin(), isDev && new CaseSensitivePathsPlugin(), isDev && new ReactRefreshPlugin({
305
- overlay: false
306
- }), ...(isDev || process.env.OUTPUT_HTML || appConfig.single || appConfig.mainProject ? paths.indexHTML.map(template => new HtmlWebpackPlugin({
307
- template: template,
308
- filename: template.split('/').pop(),
309
- inject: false,
310
- minify: {
311
- removeComments: true,
312
- collapseWhitespace: true,
313
- removeRedundantAttributes: true,
314
- useShortDoctype: true,
315
- removeEmptyAttributes: true,
316
- removeStyleLinkTypeAttributes: true,
317
- keepClosingSlash: true,
318
- minifyJS: true,
319
- minifyCSS: true,
320
- minifyURLs: true
321
- }
322
- })) : []), process.env.ANALYZE && isProd && new BundleAnalyzerPlugin()].filter(Boolean),
315
+ plugins: [
316
+ qseCDN.isUseCommon && new webpack.DllReferencePlugin({
317
+ manifest: require("../asset/dll/libcommon3-manifest.json")
318
+ }),
319
+ new webpack.IgnorePlugin({
320
+ resourceRegExp: /^\.\/locale$/,
321
+ contextRegExp: /moment$/
322
+ }),
323
+ new webpack.DefinePlugin({
324
+ "process.env.APP_NAME": JSON.stringify(appPkg.name),
325
+ "process.env.APP_VERSION": JSON.stringify(appPkg.version),
326
+ "process.env.BABEL_ENV": JSON.stringify(process.env.BABEL_ENV),
327
+ "process.env.BROWSERSLIST": JSON.stringify(process.env.BROWSERSLIST),
328
+ "process.env.WDS_SOCKET_HOST": JSON.stringify(process.env.WDS_SOCKET_HOST),
329
+ "process.env.WDS_SOCKET_PORT": JSON.stringify(process.env.WDS_SOCKET_PORT),
330
+ ...override.define
331
+ }),
332
+ new webpack.ProgressPlugin(),
333
+ isDev && new CaseSensitivePathsPlugin(),
334
+ isDev && new ReactRefreshPlugin({ overlay: false }),
335
+ ...isDev || process.env.OUTPUT_HTML || appConfig.single || appConfig.mainProject ? paths.indexHTML.map(
336
+ (template) => new HtmlWebpackPlugin({
337
+ template,
338
+ filename: template.split("/").pop(),
339
+ inject: false,
340
+ minify: {
341
+ removeComments: true,
342
+ collapseWhitespace: true,
343
+ removeRedundantAttributes: true,
344
+ useShortDoctype: true,
345
+ removeEmptyAttributes: true,
346
+ removeStyleLinkTypeAttributes: true,
347
+ keepClosingSlash: true,
348
+ minifyJS: true,
349
+ minifyCSS: true,
350
+ minifyURLs: true
351
+ }
352
+ })
353
+ ) : [],
354
+ process.env.ANALYZE && isProd && new BundleAnalyzerPlugin()
355
+ ].filter(Boolean),
323
356
  optimization: {
324
357
  minimize: isProd && override.minify !== false,
325
- minimizer: [override.minify === 'esbuild' && new ESBuildMinifyPlugin({
326
- pure: (_override$pure_funcs = override.pure_funcs) !== null && _override$pure_funcs !== void 0 ? _override$pure_funcs : ['console.log'],
327
- drop: ['debugger'],
328
- keepNames: false,
329
- legalComments: 'none',
330
- target: 'es6'
331
- }),
332
- // This is only used in production mode
333
- override.minify === 'terser' && new TerserPlugin({
334
- extractComments: false,
335
- terserOptions: {
336
- parse: {
337
- // We want terser to parse ecma 8 code. However, we don't want it
338
- // to apply any minification steps that turns valid ecma 5 code
339
- // into invalid ecma 5 code. This is why the 'compress' and 'output'
340
- // sections only apply transformations that are ecma 5 safe
341
- // https://github.com/facebook/create-react-app/pull/4234
342
- ecma: 8
343
- },
344
- compress: {
345
- pure_funcs: (_override$pure_funcs2 = override.pure_funcs) !== null && _override$pure_funcs2 !== void 0 ? _override$pure_funcs2 : ['console.log'],
346
- drop_debugger: true,
347
- ecma: 5,
348
- warnings: false,
349
- // Disabled because of an issue with Uglify breaking seemingly valid code:
350
- // https://github.com/facebook/create-react-app/issues/2376
351
- // Pending further investigation:
352
- // https://github.com/mishoo/UglifyJS2/issues/2011
353
- comparisons: false,
354
- // Disabled because of an issue with Terser breaking valid code:
355
- // https://github.com/facebook/create-react-app/issues/5250
356
- // Pending further investigation:
357
- // https://github.com/terser-js/terser/issues/120
358
- inline: 2
359
- },
360
- mangle: {
361
- safari10: true
362
- },
363
- // Added for profiling in devtools
364
- keep_classnames: false,
365
- keep_fnames: false,
366
- output: {
367
- ecma: 5,
368
- comments: false,
369
- // Turned on because emoji and regex is not minified properly using default
370
- // https://github.com/facebook/create-react-app/issues/2488
371
- ascii_only: true
358
+ minimizer: [
359
+ override.minify === "esbuild" && new ESBuildMinifyPlugin({
360
+ pure: override.pure_funcs ?? ["console.log"],
361
+ drop: ["debugger"],
362
+ keepNames: false,
363
+ legalComments: "none",
364
+ target: "es6"
365
+ }),
366
+ // This is only used in production mode
367
+ override.minify === "terser" && new TerserPlugin({
368
+ extractComments: false,
369
+ terserOptions: {
370
+ parse: {
371
+ // We want terser to parse ecma 8 code. However, we don't want it
372
+ // to apply any minification steps that turns valid ecma 5 code
373
+ // into invalid ecma 5 code. This is why the 'compress' and 'output'
374
+ // sections only apply transformations that are ecma 5 safe
375
+ // https://github.com/facebook/create-react-app/pull/4234
376
+ ecma: 8
377
+ },
378
+ compress: {
379
+ pure_funcs: override.pure_funcs ?? ["console.log"],
380
+ drop_debugger: true,
381
+ ecma: 5,
382
+ warnings: false,
383
+ // Disabled because of an issue with Uglify breaking seemingly valid code:
384
+ // https://github.com/facebook/create-react-app/issues/2376
385
+ // Pending further investigation:
386
+ // https://github.com/mishoo/UglifyJS2/issues/2011
387
+ comparisons: false,
388
+ // Disabled because of an issue with Terser breaking valid code:
389
+ // https://github.com/facebook/create-react-app/issues/5250
390
+ // Pending further investigation:
391
+ // https://github.com/terser-js/terser/issues/120
392
+ inline: 2
393
+ },
394
+ mangle: {
395
+ safari10: true
396
+ },
397
+ // Added for profiling in devtools
398
+ keep_classnames: false,
399
+ keep_fnames: false,
400
+ output: {
401
+ ecma: 5,
402
+ comments: false,
403
+ // Turned on because emoji and regex is not minified properly using default
404
+ // https://github.com/facebook/create-react-app/issues/2488
405
+ ascii_only: true
406
+ }
372
407
  }
373
- }
374
- })].filter(Boolean),
408
+ })
409
+ ].filter(Boolean),
375
410
  splitChunks: {
376
411
  minChunks: 2
377
412
  }
@@ -382,4 +417,4 @@ module.exports = function getWebpackConfig(args, override) {
382
417
  }
383
418
  };
384
419
  return config;
385
- };
420
+ };