@s-ui/bundler 8.0.0-beta.1 → 8.0.0-beta.13
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.
- package/README.md +0 -12
- package/bin/sui-bundler-build.js +7 -6
- package/bin/sui-bundler-dev.js +17 -6
- package/bin/sui-bundler-lib.js +1 -1
- package/factories/createDevServerConfig.js +11 -5
- package/loaders/linkLoaderConfigBuilder.js +1 -2
- package/package.json +10 -11
- package/shared/config.js +1 -3
- package/shared/minify-js.js +3 -56
- package/utils/formatWebpackMessages.js +2 -2
- package/utils/ignoredFiles.js +22 -0
- package/utils/noopServiceWorkerMiddleware.js +40 -0
- package/webpack.config.dev.js +4 -1
- package/webpack.config.prod.js +11 -10
- package/webpack.config.server.js +9 -3
package/README.md
CHANGED
|
@@ -183,10 +183,6 @@ This tool works with zero configuration out the box but you could use some confi
|
|
|
183
183
|
"sourcemaps": {
|
|
184
184
|
"dev": "cheap-module-eval-source-map",
|
|
185
185
|
"prod": "hidden-source-map"
|
|
186
|
-
},
|
|
187
|
-
"optimizations": {
|
|
188
|
-
"splitFrameworkOnChunk": true,
|
|
189
|
-
"useExperimentalMinifier": true
|
|
190
186
|
}
|
|
191
187
|
}
|
|
192
188
|
}
|
|
@@ -314,14 +310,6 @@ Different values can be configured for development (`dev`) and production (`prod
|
|
|
314
310
|
|
|
315
311
|
Check all possible values accepted by webpack in the [devtool webpack docs](https://webpack.js.org/configuration/devtool/#devtool)
|
|
316
312
|
|
|
317
|
-
## Optimizations
|
|
318
|
-
|
|
319
|
-
You could tweak the performance of your bundle generation by using some flags provided in this config.
|
|
320
|
-
|
|
321
|
-
`splitFrameworkOnChunk` (default: `false`): Separate in a chunk all the packages related to React. This gives you a separated static hashed file, as the version of React doesn't get often upgraded, and a benefit over HTTP2 connections are you're serving smaller files.
|
|
322
|
-
|
|
323
|
-
`useExperimentalMinifier` (default: `false`): Use `esbuild-loader` to minify JavaScript and CSS instead using `terser` and `css-minimizer-webpack-plugin` in order to boost build time and memory usage.
|
|
324
|
-
|
|
325
313
|
## Migrations
|
|
326
314
|
|
|
327
315
|
### Migrate from v7 to v8
|
package/bin/sui-bundler-build.js
CHANGED
|
@@ -6,7 +6,6 @@ const path = require('path')
|
|
|
6
6
|
const program = require('commander')
|
|
7
7
|
const rimraf = require('rimraf')
|
|
8
8
|
const webpack = require('webpack')
|
|
9
|
-
const {minify} = require('terser')
|
|
10
9
|
const {writeFile} = require('@s-ui/helpers/file')
|
|
11
10
|
|
|
12
11
|
const config = require('../webpack.config.prod')
|
|
@@ -39,9 +38,13 @@ program
|
|
|
39
38
|
})
|
|
40
39
|
.parse(process.argv)
|
|
41
40
|
|
|
42
|
-
const {
|
|
41
|
+
const {
|
|
42
|
+
clean = false,
|
|
43
|
+
context,
|
|
44
|
+
linkPackage: packagesToLink = []
|
|
45
|
+
} = program.opts()
|
|
46
|
+
|
|
43
47
|
config.context = context || config.context
|
|
44
|
-
const packagesToLink = program.linkPackage || []
|
|
45
48
|
|
|
46
49
|
const nextConfig = packagesToLink.length
|
|
47
50
|
? linkLoaderConfigBuilder({
|
|
@@ -72,7 +75,6 @@ webpack(nextConfig).run(async (error, stats) => {
|
|
|
72
75
|
if (stats.hasWarnings()) {
|
|
73
76
|
const jsonStats = stats.toJson('errors-warnings')
|
|
74
77
|
log.warn('Webpack generated the following warnings: ')
|
|
75
|
-
log.warn(jsonStats.warnings)
|
|
76
78
|
jsonStats.warnings.map(({message}) => log.warn(message))
|
|
77
79
|
}
|
|
78
80
|
|
|
@@ -133,10 +135,9 @@ webpack(nextConfig).run(async (error, stats) => {
|
|
|
133
135
|
JSON.stringify(staticsCacheOnly)
|
|
134
136
|
)
|
|
135
137
|
|
|
136
|
-
const {code: minifiedSw} = await minify(swCode, {sourceMap: false})
|
|
137
138
|
const swFilePath = resolvePublicFile('service-worker.js')
|
|
138
139
|
|
|
139
|
-
await writeFile(swFilePath,
|
|
140
|
+
await writeFile(swFilePath, swCode)
|
|
140
141
|
console.log('\nService worker generated succesfully!\n')
|
|
141
142
|
}
|
|
142
143
|
|
package/bin/sui-bundler-dev.js
CHANGED
|
@@ -24,8 +24,9 @@ const createCompiler = require('../factories/createCompiler')
|
|
|
24
24
|
const linkLoaderConfigBuilder = require('../loaders/linkLoaderConfigBuilder')
|
|
25
25
|
const log = require('../shared/log')
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
const
|
|
27
|
+
const {CI = false, HOST = '0.0.0.0', HTTPS, PORT} = process.env
|
|
28
|
+
const DEFAULT_PORT = +PORT || 3000
|
|
29
|
+
const DEFAULT_WATCH = !CI
|
|
29
30
|
|
|
30
31
|
if (!module.parent) {
|
|
31
32
|
program
|
|
@@ -43,6 +44,11 @@ if (!module.parent) {
|
|
|
43
44
|
},
|
|
44
45
|
[]
|
|
45
46
|
)
|
|
47
|
+
.option(
|
|
48
|
+
'-w, --watch',
|
|
49
|
+
'Watch files and restart the server on change',
|
|
50
|
+
DEFAULT_WATCH
|
|
51
|
+
)
|
|
46
52
|
.on('--help', () => {
|
|
47
53
|
console.log(' Examples:')
|
|
48
54
|
console.log('')
|
|
@@ -52,13 +58,15 @@ if (!module.parent) {
|
|
|
52
58
|
console.log('')
|
|
53
59
|
})
|
|
54
60
|
.parse(process.argv)
|
|
55
|
-
|
|
61
|
+
|
|
62
|
+
const {context} = program.opts()
|
|
63
|
+
|
|
56
64
|
webpackConfig.context = context || webpackConfig.context
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
const start = async ({
|
|
60
68
|
config = webpackConfig,
|
|
61
|
-
packagesToLink = program.linkPackage || []
|
|
69
|
+
packagesToLink = program.opts().linkPackage || []
|
|
62
70
|
} = {}) => {
|
|
63
71
|
clearConsole()
|
|
64
72
|
// Warn and crash if required files are missing
|
|
@@ -73,14 +81,16 @@ const start = async ({
|
|
|
73
81
|
)
|
|
74
82
|
process.exit(1)
|
|
75
83
|
}
|
|
76
|
-
|
|
84
|
+
|
|
85
|
+
const protocol = HTTPS === 'true' ? 'https' : 'http'
|
|
77
86
|
const port = await choosePort(HOST, DEFAULT_PORT)
|
|
78
87
|
const urls = prepareUrls(protocol, HOST, port)
|
|
79
88
|
const nextConfig = linkLoaderConfigBuilder({
|
|
80
89
|
config,
|
|
81
|
-
linkAll: program.linkAll,
|
|
90
|
+
linkAll: program.opts().linkAll,
|
|
82
91
|
packagesToLink
|
|
83
92
|
})
|
|
93
|
+
|
|
84
94
|
const compiler = createCompiler(nextConfig, urls)
|
|
85
95
|
const serverConfig = createDevServerConfig(nextConfig, urls.lanUrlForConfig)
|
|
86
96
|
const devServer = new WebpackDevServer(
|
|
@@ -91,6 +101,7 @@ const start = async ({
|
|
|
91
101
|
},
|
|
92
102
|
compiler
|
|
93
103
|
)
|
|
104
|
+
|
|
94
105
|
log.processing('❯ Starting the development server...\n')
|
|
95
106
|
devServer.startCallback(err => {
|
|
96
107
|
if (err) return log.error(err)
|
package/bin/sui-bundler-lib.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
const noopServiceWorkerMiddleware = require('
|
|
4
|
-
const ignoredFiles = require('
|
|
3
|
+
const noopServiceWorkerMiddleware = require('../utils/noopServiceWorkerMiddleware.js')
|
|
4
|
+
const ignoredFiles = require('../utils/ignoredFiles.js')
|
|
5
5
|
|
|
6
6
|
const {HOST, HTTPS} = process.env
|
|
7
7
|
const protocol = HTTPS === 'true' ? 'https' : 'http'
|
|
8
8
|
const host = HOST || '0.0.0.0'
|
|
9
9
|
|
|
10
|
+
const getWatchOptions = ({context, watch}) => {
|
|
11
|
+
return watch
|
|
12
|
+
? {
|
|
13
|
+
ignored: ignoredFiles(context)
|
|
14
|
+
}
|
|
15
|
+
: false
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
module.exports = config => ({
|
|
11
19
|
allowedHosts: 'all',
|
|
12
20
|
client: {
|
|
@@ -19,9 +27,7 @@ module.exports = config => ({
|
|
|
19
27
|
},
|
|
20
28
|
static: {
|
|
21
29
|
directory: 'public',
|
|
22
|
-
watch:
|
|
23
|
-
ignored: ignoredFiles(config.context)
|
|
24
|
-
}
|
|
30
|
+
watch: getWatchOptions(config)
|
|
25
31
|
},
|
|
26
32
|
hot: true,
|
|
27
33
|
https: protocol === 'https',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const fg = require('fast-glob')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
|
|
4
|
-
const {config} = require('../shared')
|
|
5
4
|
const log = require('../shared/log')
|
|
6
5
|
const {defaultAlias} = require('../shared/resolve-alias')
|
|
7
6
|
const createSassLinkImporter = require('./sassLinkImporter.js')
|
|
@@ -81,7 +80,7 @@ module.exports = ({config, packagesToLink, linkAll}) => {
|
|
|
81
80
|
const {rules} = config.module
|
|
82
81
|
const rulesWithLink = rules.map(rule => {
|
|
83
82
|
const {use, test: regex} = rule
|
|
84
|
-
if (!regex.test('.css')
|
|
83
|
+
if (!regex.test('.css')) return rule
|
|
85
84
|
|
|
86
85
|
return {
|
|
87
86
|
...rule,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s-ui/bundler",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.13",
|
|
4
4
|
"description": "Config-free bundler for ES6 React apps.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sui-bundler": "./bin/sui-bundler.js"
|
|
@@ -27,25 +27,24 @@
|
|
|
27
27
|
"autoprefixer": "10.4.0",
|
|
28
28
|
"babel-loader": "8.2.3",
|
|
29
29
|
"babel-preset-sui": "3",
|
|
30
|
-
"commander": "
|
|
30
|
+
"commander": "8.3.0",
|
|
31
31
|
"css-loader": "6.5.1",
|
|
32
|
-
"css-minimizer-webpack-plugin": "3.
|
|
32
|
+
"css-minimizer-webpack-plugin": "3.2.0",
|
|
33
33
|
"esbuild-loader": "2.16.0",
|
|
34
|
+
"escape-string-regexp": "5.0.0",
|
|
34
35
|
"fast-glob": "3.2.7",
|
|
35
36
|
"html-webpack-plugin": "5.5.0",
|
|
36
|
-
"mini-css-extract-plugin": "2.4.
|
|
37
|
-
"null-loader": "4.0.1",
|
|
37
|
+
"mini-css-extract-plugin": "2.4.5",
|
|
38
38
|
"process": "0.11.10",
|
|
39
|
-
"postcss": "8.
|
|
40
|
-
"postcss-loader": "6.2.
|
|
39
|
+
"postcss": "8.4.4",
|
|
40
|
+
"postcss-loader": "6.2.1",
|
|
41
41
|
"react-dev-utils": "11.0.4",
|
|
42
42
|
"rimraf": "3.0.2",
|
|
43
|
-
"sass": "1.43.
|
|
43
|
+
"sass": "1.43.5",
|
|
44
44
|
"speed-measure-webpack-plugin": "1.5.0",
|
|
45
45
|
"style-loader": "3.3.1",
|
|
46
|
-
"
|
|
47
|
-
"webpack": "
|
|
48
|
-
"webpack-dev-server": "4.4.0",
|
|
46
|
+
"webpack": "5.64.4",
|
|
47
|
+
"webpack-dev-server": "4.6.0",
|
|
49
48
|
"webpack-manifest-plugin": "4.0.2",
|
|
50
49
|
"webpack-node-externals": "3.0.0"
|
|
51
50
|
}
|
package/shared/config.js
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
const {
|
|
3
3
|
config: packageJsonConfig = {}
|
|
4
4
|
} = require(`${process.cwd()}/package.json`)
|
|
5
|
-
const {'sui-bundler': config = {}} = packageJsonConfig
|
|
6
5
|
|
|
6
|
+
const {'sui-bundler': config = {}} = packageJsonConfig
|
|
7
7
|
const {extractComments, sourcemaps} = config
|
|
8
8
|
|
|
9
9
|
exports.config = config
|
|
10
|
-
exports.useExperimentalMinifier =
|
|
11
|
-
config.optimizations && config.optimizations.useExperimentalMinifier
|
|
12
10
|
exports.extractComments = extractComments || false
|
|
13
11
|
exports.sourceMap = (sourcemaps && sourcemaps.prod) || false
|
package/shared/minify-js.js
CHANGED
|
@@ -1,63 +1,10 @@
|
|
|
1
1
|
const {ESBuildMinifyPlugin} = require('esbuild-loader')
|
|
2
|
-
const TerserPlugin = require('terser-webpack-plugin')
|
|
3
|
-
const {CI = false} = process.env
|
|
4
|
-
const CI_PARALLEL_CORES = 2
|
|
5
2
|
|
|
6
|
-
const
|
|
7
|
-
new TerserPlugin({
|
|
8
|
-
extractComments,
|
|
9
|
-
terserOptions: {
|
|
10
|
-
parse: {
|
|
11
|
-
// we want terser to parse ecma 8 code. However, we don't want it
|
|
12
|
-
// to apply any minfication steps that turns valid ecma 5 code
|
|
13
|
-
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
14
|
-
// sections only apply transformations that are ecma 5 safe
|
|
15
|
-
// https://github.com/facebook/create-react-app/pull/4234
|
|
16
|
-
ecma: 8
|
|
17
|
-
},
|
|
18
|
-
compress: {
|
|
19
|
-
ecma: 5,
|
|
20
|
-
warnings: false,
|
|
21
|
-
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
22
|
-
// https://github.com/facebook/create-react-app/issues/2376
|
|
23
|
-
// Pending further investigation:
|
|
24
|
-
// https://github.com/mishoo/UglifyJS2/issues/2011
|
|
25
|
-
comparisons: false,
|
|
26
|
-
// Disabled because of an issue with Terser breaking valid code:
|
|
27
|
-
// https://github.com/facebook/create-react-app/issues/5250
|
|
28
|
-
// Pending futher investigation:
|
|
29
|
-
// https://github.com/terser-js/terser/issues/120
|
|
30
|
-
inline: 2
|
|
31
|
-
},
|
|
32
|
-
mangle: {
|
|
33
|
-
safari10: true
|
|
34
|
-
},
|
|
35
|
-
output: {
|
|
36
|
-
ecma: 5,
|
|
37
|
-
comments: false,
|
|
38
|
-
// Turned on because emoji and regex is not minified properly using default
|
|
39
|
-
// https://github.com/facebook/create-react-app/issues/2488
|
|
40
|
-
ascii_only: true
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
// Use multi-process parallel running to improve the build speed
|
|
44
|
-
// For CI: Use only fixed cores as it gives incorrect info and could cause troubles
|
|
45
|
-
// Related: https://github.com/webpack-contrib/terser-webpack-plugin/issues/202
|
|
46
|
-
// If not CI then use os.cpus().length - 1
|
|
47
|
-
parallel: CI ? CI_PARALLEL_CORES : true,
|
|
48
|
-
// Enable file caching
|
|
49
|
-
cache: true,
|
|
50
|
-
// use sourceMap if parameter is provided
|
|
51
|
-
sourceMap: !!sourceMap
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
const esbuild = ({extractComments, sourceMap}) =>
|
|
3
|
+
const esbuild = ({sourceMap}) =>
|
|
55
4
|
new ESBuildMinifyPlugin({
|
|
56
5
|
target: 'es6',
|
|
57
6
|
sourcemap: sourceMap !== 'none' && sourceMap !== false
|
|
58
7
|
})
|
|
59
8
|
|
|
60
|
-
module.exports = ({extractComments, sourceMap
|
|
61
|
-
|
|
62
|
-
? esbuild({extractComments, sourceMap})
|
|
63
|
-
: terser({extractComments, sourceMap})
|
|
9
|
+
module.exports = ({extractComments, sourceMap}) =>
|
|
10
|
+
esbuild({extractComments, sourceMap})
|
|
@@ -113,8 +113,8 @@ function formatMessage(message) {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
function formatWebpackMessages(json) {
|
|
116
|
-
const formattedErrors = json.errors
|
|
117
|
-
const formattedWarnings = json.warnings
|
|
116
|
+
const formattedErrors = json.errors?.map(formatMessage)
|
|
117
|
+
const formattedWarnings = json.warnings?.map(formatMessage)
|
|
118
118
|
const result = {errors: formattedErrors, warnings: formattedWarnings}
|
|
119
119
|
if (result.errors.some(isLikelyASyntaxError)) {
|
|
120
120
|
// If there are any syntax errors, show just them.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Extracted from: https://github.com/facebook/create-react-app/blob/bb64e31a81eb12d688c14713dce812143688750a/packages/react-dev-utils/ignoredFiles.js
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict'
|
|
11
|
+
|
|
12
|
+
const path = require('path')
|
|
13
|
+
const escape = require('escape-string-regexp')
|
|
14
|
+
|
|
15
|
+
module.exports = function ignoredFiles(appSrc) {
|
|
16
|
+
return new RegExp(
|
|
17
|
+
`^(?!${escape(
|
|
18
|
+
path.normalize(appSrc + '/').replace(/[\\]+/g, '/')
|
|
19
|
+
)}).+/node_modules/`,
|
|
20
|
+
'g'
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// from: https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/noopServiceWorkerMiddleware.js
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict'
|
|
11
|
+
|
|
12
|
+
const path = require('path')
|
|
13
|
+
|
|
14
|
+
module.exports = function createNoopServiceWorkerMiddleware(servedPath) {
|
|
15
|
+
return function noopServiceWorkerMiddleware(req, res, next) {
|
|
16
|
+
if (req.url === path.join(servedPath, 'service-worker.js')) {
|
|
17
|
+
res.setHeader('Content-Type', 'text/javascript')
|
|
18
|
+
res.send(
|
|
19
|
+
`// This service worker file is effectively a 'no-op' that will reset any
|
|
20
|
+
// previous service worker registered for the same host:port combination.
|
|
21
|
+
// In the production build, this file is replaced with an actual service worker
|
|
22
|
+
// file that will precache your site's local assets.
|
|
23
|
+
// See https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
|
|
24
|
+
self.addEventListener('install', () => self.skipWaiting());
|
|
25
|
+
self.addEventListener('activate', () => {
|
|
26
|
+
self.clients.matchAll({ type: 'window' }).then(windowClients => {
|
|
27
|
+
for (let windowClient of windowClients) {
|
|
28
|
+
// Force open pages to refresh, so that they have a chance to load the
|
|
29
|
+
// fresh navigation response from the local dev server.
|
|
30
|
+
windowClient.navigate(windowClient.url);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
`
|
|
35
|
+
)
|
|
36
|
+
} else {
|
|
37
|
+
next()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
package/webpack.config.dev.js
CHANGED
|
@@ -16,6 +16,8 @@ const EXCLUDED_FOLDERS_REGEXP = new RegExp(
|
|
|
16
16
|
)
|
|
17
17
|
const outputPath = path.join(process.cwd(), 'dist')
|
|
18
18
|
|
|
19
|
+
const {CI = false} = process.env
|
|
20
|
+
|
|
19
21
|
process.env.NODE_ENV = 'development'
|
|
20
22
|
|
|
21
23
|
const smp = new SpeedMeasurePlugin()
|
|
@@ -44,6 +46,7 @@ const webpackConfig = {
|
|
|
44
46
|
]),
|
|
45
47
|
target: 'web',
|
|
46
48
|
optimization: {
|
|
49
|
+
checkWasmTypes: false,
|
|
47
50
|
emitOnErrors: false,
|
|
48
51
|
removeAvailableModules: false,
|
|
49
52
|
removeEmptyChunks: false,
|
|
@@ -115,7 +118,7 @@ const webpackConfig = {
|
|
|
115
118
|
)
|
|
116
119
|
])
|
|
117
120
|
},
|
|
118
|
-
watch:
|
|
121
|
+
watch: !CI,
|
|
119
122
|
devtool:
|
|
120
123
|
config.sourcemaps && config.sourcemaps.dev ? config.sourcemaps.dev : false
|
|
121
124
|
}
|
package/webpack.config.prod.js
CHANGED
|
@@ -21,11 +21,7 @@ const minifyCss = require('./shared/minify-css')
|
|
|
21
21
|
const definePlugin = require('./shared/define')
|
|
22
22
|
const babelRules = require('./shared/module-rules-babel')
|
|
23
23
|
const manifestLoaderRules = require('./shared/module-rules-manifest-loader')
|
|
24
|
-
const {
|
|
25
|
-
extractComments,
|
|
26
|
-
useExperimentalMinifier,
|
|
27
|
-
sourceMap
|
|
28
|
-
} = require('./shared/config')
|
|
24
|
+
const {extractComments, sourceMap} = require('./shared/config')
|
|
29
25
|
const {aliasFromConfig} = require('./shared/resolve-alias')
|
|
30
26
|
const {resolveLoader} = require('./shared/resolve-loader')
|
|
31
27
|
|
|
@@ -51,7 +47,12 @@ const webpackConfig = {
|
|
|
51
47
|
resolve: {
|
|
52
48
|
alias: {...aliasFromConfig},
|
|
53
49
|
extensions: ['.js', '.json'],
|
|
54
|
-
modules: ['node_modules', path.resolve(process.cwd())]
|
|
50
|
+
modules: ['node_modules', path.resolve(process.cwd())],
|
|
51
|
+
fallback: {
|
|
52
|
+
assert: false,
|
|
53
|
+
fs: false,
|
|
54
|
+
path: false
|
|
55
|
+
}
|
|
55
56
|
},
|
|
56
57
|
entry: MAIN_ENTRY_POINT,
|
|
57
58
|
output: {
|
|
@@ -61,11 +62,11 @@ const webpackConfig = {
|
|
|
61
62
|
publicPath: PUBLIC_PATH
|
|
62
63
|
},
|
|
63
64
|
optimization: {
|
|
65
|
+
checkWasmTypes: false,
|
|
64
66
|
minimize: true,
|
|
65
|
-
minimizer: [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
].filter(Boolean),
|
|
67
|
+
minimizer: [minifyJs({extractComments, sourceMap}), minifyCss()].filter(
|
|
68
|
+
Boolean
|
|
69
|
+
),
|
|
69
70
|
runtimeChunk: true
|
|
70
71
|
},
|
|
71
72
|
plugins: cleanList([
|
package/webpack.config.server.js
CHANGED
|
@@ -10,6 +10,9 @@ const {resolveLoader} = require('./shared/resolve-loader')
|
|
|
10
10
|
|
|
11
11
|
const filename = '[name].[chunkhash:8].js'
|
|
12
12
|
|
|
13
|
+
/** @typedef {import('webpack').Configuration} WebpackConfig */
|
|
14
|
+
|
|
15
|
+
/** @type {WebpackConfig} */
|
|
13
16
|
const webpackConfig = {
|
|
14
17
|
context: path.resolve(process.cwd(), 'src'),
|
|
15
18
|
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
|
@@ -37,9 +40,12 @@ const webpackConfig = {
|
|
|
37
40
|
rules: cleanList([
|
|
38
41
|
babelRules,
|
|
39
42
|
{
|
|
40
|
-
// ignore css/scss require/imports files in the server
|
|
41
|
-
test: /\.s?css$/,
|
|
42
|
-
|
|
43
|
+
// ignore css/scss/svg require/imports files in the server
|
|
44
|
+
test: [/\.s?css$/, /\.svg$/],
|
|
45
|
+
type: 'asset/inline',
|
|
46
|
+
generator: {
|
|
47
|
+
dataUrl: () => ''
|
|
48
|
+
}
|
|
43
49
|
},
|
|
44
50
|
when(config['externals-manifest'], () =>
|
|
45
51
|
manifestLoaderRules(config['externals-manifest'])
|