@s-ui/bundler 9.43.0 → 9.44.0
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/bin/sui-bundler-build.js +8 -30
- package/bin/sui-bundler-dev.js +5 -22
- package/bin/sui-bundler-lib.js +3 -13
- package/bin/sui-bundler.js +1 -4
- package/factories/createCompiler.js +2 -6
- package/loaders/ExternalsManifestLoader.js +1 -3
- package/loaders/linkLoaderConfigBuilder.js +2 -8
- package/loaders/sassLinkImporter.js +1 -4
- package/package.json +1 -1
- package/service-worker.js +1 -3
- package/shared/config.js +2 -8
- package/shared/inline-chunk-html-plugin.js +2 -5
- package/shared/minify-js.js +1 -3
- package/shared/module-rules-babel.js +2 -8
- package/shared/resolve-alias.js +4 -15
- package/shared/resolve-loader.js +1 -3
- package/utils/WebpackDevServerUtils.js +10 -42
- package/utils/clearConsole.js +1 -3
- package/utils/formatWebpackMessages.js +6 -20
- package/utils/getProcessForPort.js +4 -19
- package/utils/ignoredFiles.js +1 -6
- package/webpack.config.dev.js +3 -12
- package/webpack.config.lib.js +2 -11
- package/webpack.config.prod.js +6 -24
- package/webpack.config.server.dev.js +119 -0
- package/webpack.config.server.js +1 -3
package/bin/sui-bundler-build.js
CHANGED
|
@@ -41,12 +41,7 @@ program
|
|
|
41
41
|
})
|
|
42
42
|
.parse(process.argv)
|
|
43
43
|
|
|
44
|
-
const {
|
|
45
|
-
clean = false,
|
|
46
|
-
context,
|
|
47
|
-
saveStats,
|
|
48
|
-
linkPackage: packagesToLink = []
|
|
49
|
-
} = program.opts()
|
|
44
|
+
const {clean = false, context, saveStats, linkPackage: packagesToLink = []} = program.opts()
|
|
50
45
|
|
|
51
46
|
config.context = context || config.context
|
|
52
47
|
|
|
@@ -106,10 +101,7 @@ compiler.run(async (error, stats) => {
|
|
|
106
101
|
const resolvePublicFile = file => path.resolve(process.cwd(), 'public', file)
|
|
107
102
|
|
|
108
103
|
if (offlinePageExists) {
|
|
109
|
-
fs.copyFileSync(
|
|
110
|
-
path.resolve(offlinePath),
|
|
111
|
-
resolvePublicFile('offline.html')
|
|
112
|
-
)
|
|
104
|
+
fs.copyFileSync(path.resolve(offlinePath), resolvePublicFile('offline.html'))
|
|
113
105
|
}
|
|
114
106
|
|
|
115
107
|
if (offlinePageExists || staticsCacheOnly) {
|
|
@@ -126,31 +118,19 @@ compiler.run(async (error, stats) => {
|
|
|
126
118
|
|
|
127
119
|
const importScripts = offlineConfig.importScripts || []
|
|
128
120
|
|
|
129
|
-
const stringImportScripts = importScripts
|
|
130
|
-
.map(url => `importScripts("${url}")`)
|
|
131
|
-
.join('\n')
|
|
121
|
+
const stringImportScripts = importScripts.map(url => `importScripts("${url}")`).join('\n')
|
|
132
122
|
|
|
133
|
-
Boolean(importScripts.length) &&
|
|
134
|
-
console.log('\nExternal Scripts Added to the SW:\n', stringImportScripts)
|
|
123
|
+
Boolean(importScripts.length) && console.log('\nExternal Scripts Added to the SW:\n', stringImportScripts)
|
|
135
124
|
|
|
136
125
|
// read the service worker template
|
|
137
|
-
const swTemplate = fs.readFileSync(
|
|
138
|
-
path.resolve(__dirname, '..', 'service-worker.js'),
|
|
139
|
-
'utf-8'
|
|
140
|
-
)
|
|
126
|
+
const swTemplate = fs.readFileSync(path.resolve(__dirname, '..', 'service-worker.js'), 'utf-8')
|
|
141
127
|
|
|
142
128
|
// replace all the variables from the template with the actual values
|
|
143
129
|
const swCode = swTemplate
|
|
144
130
|
.replace('// IMPORT_SCRIPTS_HERE', stringImportScripts)
|
|
145
131
|
.replace("require('static-manifest')", JSON.stringify(manifestStatics))
|
|
146
|
-
.replace(
|
|
147
|
-
|
|
148
|
-
JSON.stringify(Date.now().toString())
|
|
149
|
-
)
|
|
150
|
-
.replace(
|
|
151
|
-
"require('static-statics-cache-only')",
|
|
152
|
-
JSON.stringify(staticsCacheOnly)
|
|
153
|
-
)
|
|
132
|
+
.replace("require('static-cache-name')", JSON.stringify(Date.now().toString()))
|
|
133
|
+
.replace("require('static-statics-cache-only')", JSON.stringify(staticsCacheOnly))
|
|
154
134
|
|
|
155
135
|
const swFilePath = resolvePublicFile('service-worker.js')
|
|
156
136
|
|
|
@@ -158,9 +138,7 @@ compiler.run(async (error, stats) => {
|
|
|
158
138
|
console.log('\nService worker generated succesfully!\n')
|
|
159
139
|
}
|
|
160
140
|
|
|
161
|
-
log.success(
|
|
162
|
-
`Your app is compiled in ${process.env.NODE_ENV} mode in /public. It's ready to roll!`
|
|
163
|
-
)
|
|
141
|
+
log.success(`Your app is compiled in ${process.env.NODE_ENV} mode in /public. It's ready to roll!`)
|
|
164
142
|
|
|
165
143
|
compiler.close(closeErr => {
|
|
166
144
|
const exitCode = closeErr ? 1 : 0
|
package/bin/sui-bundler-dev.js
CHANGED
|
@@ -28,10 +28,7 @@ const DEFAULT_WATCH = !CI
|
|
|
28
28
|
if (!module.parent) {
|
|
29
29
|
program
|
|
30
30
|
.option('-c, --context [folder]', 'Context folder (cwd by default)')
|
|
31
|
-
.option(
|
|
32
|
-
'-L, --link-all [monorepo]',
|
|
33
|
-
'Link all packages inside of monorepo multipackage'
|
|
34
|
-
)
|
|
31
|
+
.option('-L, --link-all [monorepo]', 'Link all packages inside of monorepo multipackage')
|
|
35
32
|
.option(
|
|
36
33
|
'-l, --link-package [package]',
|
|
37
34
|
'Replace each occurrence of this package with an absolute path to this folder',
|
|
@@ -41,11 +38,7 @@ if (!module.parent) {
|
|
|
41
38
|
},
|
|
42
39
|
[]
|
|
43
40
|
)
|
|
44
|
-
.option(
|
|
45
|
-
'-w, --watch',
|
|
46
|
-
'Watch files and restart the server on change',
|
|
47
|
-
DEFAULT_WATCH
|
|
48
|
-
)
|
|
41
|
+
.option('-w, --watch', 'Watch files and restart the server on change', DEFAULT_WATCH)
|
|
49
42
|
.on('--help', () => {
|
|
50
43
|
console.log(' Examples:')
|
|
51
44
|
console.log('')
|
|
@@ -61,21 +54,11 @@ if (!module.parent) {
|
|
|
61
54
|
webpackConfig.context = context || webpackConfig.context
|
|
62
55
|
}
|
|
63
56
|
|
|
64
|
-
const start = async ({
|
|
65
|
-
config = webpackConfig,
|
|
66
|
-
packagesToLink = program.opts().linkPackage || []
|
|
67
|
-
} = {}) => {
|
|
57
|
+
const start = async ({config = webpackConfig, packagesToLink = program.opts().linkPackage || []} = {}) => {
|
|
68
58
|
clearConsole()
|
|
69
59
|
// Warn and crash if required files are missing
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
path.join(config.context, 'index.html'),
|
|
73
|
-
path.join(config.context, 'app.js')
|
|
74
|
-
])
|
|
75
|
-
) {
|
|
76
|
-
log.error(
|
|
77
|
-
`✖ Required files are missing, create and index.html and app.js inside your src folder.`
|
|
78
|
-
)
|
|
60
|
+
if (!checkRequiredFiles([path.join(config.context, 'index.html'), path.join(config.context, 'app.js')])) {
|
|
61
|
+
log.error(`✖ Required files are missing, create and index.html and app.js inside your src folder.`)
|
|
79
62
|
process.exit(1)
|
|
80
63
|
}
|
|
81
64
|
|
package/bin/sui-bundler-lib.js
CHANGED
|
@@ -16,10 +16,7 @@ program
|
|
|
16
16
|
.option('-o, --output [output]', 'Bundle folder path')
|
|
17
17
|
.option('-u, --umd [libraryName]', 'Whether to output library as umb')
|
|
18
18
|
.option('-r, --root', 'Create build in root dir instead of version subdir')
|
|
19
|
-
.option(
|
|
20
|
-
'-p, --path [path]',
|
|
21
|
-
'Absolute public path where files will be located.'
|
|
22
|
-
)
|
|
19
|
+
.option('-p, --path [path]', 'Absolute public path where files will be located.')
|
|
23
20
|
.on('--help', () =>
|
|
24
21
|
console.log(`Examples:
|
|
25
22
|
$ sui-bundler lib src/index.js -o umd/my-lib -p http://my-cdn.com/my-lib -C'
|
|
@@ -48,12 +45,7 @@ if (!publicPath) {
|
|
|
48
45
|
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
|
49
46
|
|
|
50
47
|
const version = getPackageJson(process.cwd()).version
|
|
51
|
-
const outputFolder = path.join(
|
|
52
|
-
process.cwd(),
|
|
53
|
-
output,
|
|
54
|
-
path.sep,
|
|
55
|
-
root ? '' : version
|
|
56
|
-
)
|
|
48
|
+
const outputFolder = path.join(process.cwd(), output, path.sep, root ? '' : version)
|
|
57
49
|
const webpackConfig = {...config, entry: path.resolve(process.cwd(), entry)}
|
|
58
50
|
webpackConfig.output.publicPath = publicPath + (root ? '' : version + '/')
|
|
59
51
|
webpackConfig.output.path = outputFolder
|
|
@@ -94,7 +86,5 @@ webpack(webpackConfig).run((error, stats) => {
|
|
|
94
86
|
}
|
|
95
87
|
|
|
96
88
|
console.log(`Webpack stats: ${stats}`)
|
|
97
|
-
log.success(
|
|
98
|
-
`Your library is compiled in production mode in: \n${outputFolder}`
|
|
99
|
-
)
|
|
89
|
+
log.success(`Your library is compiled in production mode in: \n${outputFolder}`)
|
|
100
90
|
})
|
package/bin/sui-bundler.js
CHANGED
|
@@ -9,9 +9,6 @@ program
|
|
|
9
9
|
.command('dev', 'open a server dev to start the development')
|
|
10
10
|
.command('build', 'Compile all assets and create a public folder')
|
|
11
11
|
.command('lib', 'Compile a library to a bundle with chunks.')
|
|
12
|
-
.command(
|
|
13
|
-
'analyzer',
|
|
14
|
-
'Compile all assets and create a HTML inspector for your bundle'
|
|
15
|
-
)
|
|
12
|
+
.command('analyzer', 'Compile all assets and create a HTML inspector for your bundle')
|
|
16
13
|
|
|
17
14
|
program.parse(process.argv)
|
|
@@ -32,9 +32,7 @@ module.exports = (config, urls) => {
|
|
|
32
32
|
|
|
33
33
|
// Log the correct message of compilation depending if we have warnings
|
|
34
34
|
if (isSuccessful) {
|
|
35
|
-
stats.hasWarnings()
|
|
36
|
-
? log.warn('⚠ Compiled with warnings')
|
|
37
|
-
: log.success('✔ Compiled successfully')
|
|
35
|
+
stats.hasWarnings() ? log.warn('⚠ Compiled with warnings') : log.success('✔ Compiled successfully')
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
// Even with warnings, we show instructions to access localhost if we have a compilation
|
|
@@ -52,9 +50,7 @@ module.exports = (config, urls) => {
|
|
|
52
50
|
|
|
53
51
|
// With warnings, even after showing the instructions we must list the warnings we have
|
|
54
52
|
if (stats.hasWarnings()) {
|
|
55
|
-
const messages = formatWebpackMessages(
|
|
56
|
-
stats.toJson('errors-warnings', true)
|
|
57
|
-
)
|
|
53
|
+
const messages = formatWebpackMessages(stats.toJson('errors-warnings', true))
|
|
58
54
|
log.warn(messages.warnings.join('\n\n'))
|
|
59
55
|
}
|
|
60
56
|
})
|
|
@@ -46,9 +46,7 @@ async function externalsManifestLoader(source) {
|
|
|
46
46
|
|
|
47
47
|
try {
|
|
48
48
|
const manifest = await getRemoteManifest(
|
|
49
|
-
typeof manifestURL === 'string'
|
|
50
|
-
? manifestURL
|
|
51
|
-
: manifestURL[process.env.NODE_ENV]
|
|
49
|
+
typeof manifestURL === 'string' ? manifestURL : manifestURL[process.env.NODE_ENV]
|
|
52
50
|
)
|
|
53
51
|
const entries = Object.entries(manifest)
|
|
54
52
|
const nextSource = entries.reduce((acc, entry) => {
|
|
@@ -14,9 +14,7 @@ const diccFromAbsolutePaths = (paths, init = {}) =>
|
|
|
14
14
|
log.success(`✔ ${pkg.name} from path "${packagePath}"`)
|
|
15
15
|
return acc
|
|
16
16
|
} catch (e) {
|
|
17
|
-
log.warn(
|
|
18
|
-
`⚠ Package from path "${packagePath}" can't be linked.\n Path is wrong or package.json is missing.`
|
|
19
|
-
)
|
|
17
|
+
log.warn(`⚠ Package from path "${packagePath}" can't be linked.\n Path is wrong or package.json is missing.`)
|
|
20
18
|
return acc
|
|
21
19
|
}
|
|
22
20
|
}, init)
|
|
@@ -24,11 +22,7 @@ const diccFromAbsolutePaths = (paths, init = {}) =>
|
|
|
24
22
|
const absolutePathForMonoRepo = base => {
|
|
25
23
|
if (!base) return []
|
|
26
24
|
return fg
|
|
27
|
-
.sync([
|
|
28
|
-
`${path.resolve(base)}/**/package.json`,
|
|
29
|
-
'!**/node_modules/**',
|
|
30
|
-
'!**/lib/**'
|
|
31
|
-
])
|
|
25
|
+
.sync([`${path.resolve(base)}/**/package.json`, '!**/node_modules/**', '!**/lib/**'])
|
|
32
26
|
.map(p => path.dirname(p))
|
|
33
27
|
}
|
|
34
28
|
|
|
@@ -8,10 +8,7 @@ const createSassLinkImporter = entryPoints => url => {
|
|
|
8
8
|
const [org, name] = url.split(/\//)
|
|
9
9
|
const pkg = [org.replace('~', ''), name].join('/')
|
|
10
10
|
|
|
11
|
-
const absoluteUrl = url.replace(
|
|
12
|
-
new RegExp(`~?${pkg}(\\/lib)?`, 'g'),
|
|
13
|
-
entryPoints[pkg]
|
|
14
|
-
)
|
|
11
|
+
const absoluteUrl = url.replace(new RegExp(`~?${pkg}(\\/lib)?`, 'g'), entryPoints[pkg])
|
|
15
12
|
return {file: absoluteUrl}
|
|
16
13
|
}
|
|
17
14
|
return null
|
package/package.json
CHANGED
package/service-worker.js
CHANGED
|
@@ -50,9 +50,7 @@ const copyResponse = async function (response) {
|
|
|
50
50
|
statusText: clonedResponse.statusText
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const body = canConstructResponseFromBodyStream()
|
|
54
|
-
? clonedResponse.body
|
|
55
|
-
: await clonedResponse.blob()
|
|
53
|
+
const body = canConstructResponseFromBodyStream() ? clonedResponse.body : await clonedResponse.blob()
|
|
56
54
|
|
|
57
55
|
return new Response(body, responseInit)
|
|
58
56
|
}
|
package/shared/config.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
/* Extract sui-bundler from package.json -> "config": {"sui-bundler": { ... }} */
|
|
2
|
-
const {
|
|
3
|
-
config: packageJsonConfig = {}
|
|
4
|
-
} = require(`${process.cwd()}/package.json`)
|
|
2
|
+
const {config: packageJsonConfig = {}} = require(`${process.cwd()}/package.json`)
|
|
5
3
|
|
|
6
4
|
const {'sui-bundler': config = {}} = packageJsonConfig
|
|
7
|
-
const {
|
|
8
|
-
extractComments = false,
|
|
9
|
-
sourcemaps,
|
|
10
|
-
supportLegacyBrowsers = true
|
|
11
|
-
} = config
|
|
5
|
+
const {extractComments = false, sourcemaps, supportLegacyBrowsers = true} = config
|
|
12
6
|
|
|
13
7
|
exports.config = config
|
|
14
8
|
exports.supportLegacyBrowsers = supportLegacyBrowsers
|
|
@@ -19,9 +19,7 @@ class InlineChunkHtmlPlugin {
|
|
|
19
19
|
if (tag.tagName !== 'script' || !(tag.attributes && tag.attributes.src)) {
|
|
20
20
|
return tag
|
|
21
21
|
}
|
|
22
|
-
const scriptName = publicPath
|
|
23
|
-
? tag.attributes.src.replace(publicPath, '')
|
|
24
|
-
: tag.attributes.src
|
|
22
|
+
const scriptName = publicPath ? tag.attributes.src.replace(publicPath, '') : tag.attributes.src
|
|
25
23
|
if (!this.tests.some(test => scriptName.match(test))) {
|
|
26
24
|
return tag
|
|
27
25
|
}
|
|
@@ -39,8 +37,7 @@ class InlineChunkHtmlPlugin {
|
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
compiler.hooks.compilation.tap('InlineChunkHtmlPlugin', compilation => {
|
|
42
|
-
const tagFunction = tag =>
|
|
43
|
-
this.getInlinedTag(publicPath, compilation.assets, tag)
|
|
40
|
+
const tagFunction = tag => this.getInlinedTag(publicPath, compilation.assets, tag)
|
|
44
41
|
|
|
45
42
|
const hooks = this.htmlWebpackPlugin.getHooks(compilation)
|
|
46
43
|
hooks.alterAssetTagGroups.tap('InlineChunkHtmlPlugin', assets => {
|
package/shared/minify-js.js
CHANGED
|
@@ -22,6 +22,4 @@ const terserMinifier = ({extractComments, sourceMap}) =>
|
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
module.exports = ({extractComments, sourceMap}) =>
|
|
25
|
-
supportLegacyBrowsers
|
|
26
|
-
? terserMinifier({extractComments, sourceMap})
|
|
27
|
-
: esbuildMinifier({sourceMap})
|
|
25
|
+
supportLegacyBrowsers ? terserMinifier({extractComments, sourceMap}) : esbuildMinifier({sourceMap})
|
|
@@ -5,11 +5,7 @@ const EXCLUDED_FOLDERS_REGEXP = new RegExp(
|
|
|
5
5
|
`node_modules(?!${path.sep}@s-ui(${path.sep}studio)(${path.sep}workbench)?${path.sep}src)`
|
|
6
6
|
)
|
|
7
7
|
|
|
8
|
-
module.exports = ({
|
|
9
|
-
isServer = false,
|
|
10
|
-
isDevelopment = false,
|
|
11
|
-
supportLegacyBrowsers = true
|
|
12
|
-
} = {}) => ({
|
|
8
|
+
module.exports = ({isServer = false, isDevelopment = false, supportLegacyBrowsers = true} = {}) => ({
|
|
13
9
|
test: /\.jsx?$/,
|
|
14
10
|
exclude: EXCLUDED_FOLDERS_REGEXP,
|
|
15
11
|
use: [
|
|
@@ -20,9 +16,7 @@ module.exports = ({
|
|
|
20
16
|
cacheCompression: false,
|
|
21
17
|
babelrc: false,
|
|
22
18
|
compact: true,
|
|
23
|
-
plugins: [
|
|
24
|
-
isDevelopment && require.resolve('react-refresh/babel')
|
|
25
|
-
].filter(Boolean),
|
|
19
|
+
plugins: [isDevelopment && require.resolve('react-refresh/babel')].filter(Boolean),
|
|
26
20
|
presets: [
|
|
27
21
|
[
|
|
28
22
|
require.resolve('babel-preset-sui'),
|
package/shared/resolve-alias.js
CHANGED
|
@@ -9,33 +9,22 @@ const {PWD} = process.env
|
|
|
9
9
|
* So you should use the exact same imported file from node_modules, and the linked package
|
|
10
10
|
* would try to use another different from its own node_modules. This will prevent that.
|
|
11
11
|
*/
|
|
12
|
-
const defaultPackagesToAlias = [
|
|
13
|
-
'react',
|
|
14
|
-
'react-router-dom',
|
|
15
|
-
'@s-ui/pde',
|
|
16
|
-
'@s-ui/react-context',
|
|
17
|
-
'@s-ui/react-router'
|
|
18
|
-
]
|
|
12
|
+
const defaultPackagesToAlias = ['react', 'react-router-dom', '@s-ui/pde', '@s-ui/react-context', '@s-ui/react-router']
|
|
19
13
|
|
|
20
|
-
const createAliasPath = pkgName =>
|
|
21
|
-
path.resolve(path.join(PWD, `./node_modules/${pkgName}`))
|
|
14
|
+
const createAliasPath = pkgName => path.resolve(path.join(PWD, `./node_modules/${pkgName}`))
|
|
22
15
|
|
|
23
16
|
const mustPackagesToAlias = {
|
|
24
17
|
'react/jsx-dev-runtime': 'react/jsx-dev-runtime.js',
|
|
25
18
|
'react/jsx-runtime': 'react/jsx-runtime.js'
|
|
26
19
|
}
|
|
27
20
|
|
|
28
|
-
exports.defaultAlias = Object.fromEntries(
|
|
29
|
-
defaultPackagesToAlias.map(pkgName => [pkgName, createAliasPath(pkgName)])
|
|
30
|
-
)
|
|
21
|
+
exports.defaultAlias = Object.fromEntries(defaultPackagesToAlias.map(pkgName => [pkgName, createAliasPath(pkgName)]))
|
|
31
22
|
|
|
32
23
|
const aliasFromConfig = config.alias
|
|
33
24
|
? Object.entries(config.alias).reduce(
|
|
34
25
|
(obj, [aliasName, aliasPath]) => ({
|
|
35
26
|
...obj,
|
|
36
|
-
[aliasName]: aliasPath.startsWith('./')
|
|
37
|
-
? path.join(PWD, aliasPath)
|
|
38
|
-
: aliasPath
|
|
27
|
+
[aliasName]: aliasPath.startsWith('./') ? path.join(PWD, aliasPath) : aliasPath
|
|
39
28
|
}),
|
|
40
29
|
{}
|
|
41
30
|
)
|
package/shared/resolve-loader.js
CHANGED
|
@@ -51,11 +51,7 @@ function prepareUrls(protocol, host, port, pathname = '/') {
|
|
|
51
51
|
if (lanUrlForConfig) {
|
|
52
52
|
// Check if the address is a private ip
|
|
53
53
|
// https://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces
|
|
54
|
-
if (
|
|
55
|
-
/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(
|
|
56
|
-
lanUrlForConfig
|
|
57
|
-
)
|
|
58
|
-
) {
|
|
54
|
+
if (/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(lanUrlForConfig)) {
|
|
59
55
|
// Address is private, format it for later use
|
|
60
56
|
lanUrlForTerminal = prettyPrintUrl(lanUrlForConfig)
|
|
61
57
|
} else {
|
|
@@ -94,21 +90,11 @@ function printInstructions(appName, urls, useYarn) {
|
|
|
94
90
|
|
|
95
91
|
console.log()
|
|
96
92
|
console.log('Note that the development build is not optimized.')
|
|
97
|
-
console.log(
|
|
98
|
-
`To create a production build, use ` +
|
|
99
|
-
`${cyan(`${useYarn ? 'yarn' : 'npm run'} build`)}.`
|
|
100
|
-
)
|
|
93
|
+
console.log(`To create a production build, use ` + `${cyan(`${useYarn ? 'yarn' : 'npm run'} build`)}.`)
|
|
101
94
|
console.log()
|
|
102
95
|
}
|
|
103
96
|
|
|
104
|
-
function createCompiler({
|
|
105
|
-
appName,
|
|
106
|
-
config,
|
|
107
|
-
urls,
|
|
108
|
-
useYarn,
|
|
109
|
-
useTypeScript,
|
|
110
|
-
webpack
|
|
111
|
-
}) {
|
|
97
|
+
function createCompiler({appName, config, urls, useYarn, useTypeScript, webpack}) {
|
|
112
98
|
// "Compiler" is a low-level interface to webpack.
|
|
113
99
|
// It lets us listen to some events and provide our own custom messages.
|
|
114
100
|
let compiler
|
|
@@ -181,11 +167,7 @@ function createCompiler({
|
|
|
181
167
|
console.log(messages.warnings.join('\n\n'))
|
|
182
168
|
|
|
183
169
|
// Teach some ESLint tricks.
|
|
184
|
-
console.log(
|
|
185
|
-
`\nSearch for the ${yellow(
|
|
186
|
-
'keywords'
|
|
187
|
-
)} to learn more about each warning.`
|
|
188
|
-
)
|
|
170
|
+
console.log(`\nSearch for the ${yellow('keywords')} to learn more about each warning.`)
|
|
189
171
|
}
|
|
190
172
|
})
|
|
191
173
|
|
|
@@ -221,13 +203,9 @@ function prepareProxy(proxy, appPublicFolder, servedPathname) {
|
|
|
221
203
|
if (!proxy) return undefined
|
|
222
204
|
|
|
223
205
|
if (typeof proxy !== 'string') {
|
|
224
|
-
console.log(
|
|
225
|
-
red('When specified, "proxy" in package.json must be a string.')
|
|
226
|
-
)
|
|
206
|
+
console.log(red('When specified, "proxy" in package.json must be a string.'))
|
|
227
207
|
console.log(red('Instead, the type of "proxy" was "' + typeof proxy + '".'))
|
|
228
|
-
console.log(
|
|
229
|
-
red('Either remove "proxy" from package.json, or make it a string.')
|
|
230
|
-
)
|
|
208
|
+
console.log(red('Either remove "proxy" from package.json, or make it a string.'))
|
|
231
209
|
process.exit(1)
|
|
232
210
|
}
|
|
233
211
|
|
|
@@ -237,23 +215,15 @@ function prepareProxy(proxy, appPublicFolder, servedPathname) {
|
|
|
237
215
|
const sockPath = process.env.WDS_SOCKET_PATH || '/ws'
|
|
238
216
|
const isDefaultSockHost = !process.env.WDS_SOCKET_HOST
|
|
239
217
|
function mayProxy(pathname) {
|
|
240
|
-
const maybePublicPath = path.resolve(
|
|
241
|
-
appPublicFolder,
|
|
242
|
-
pathname.replace(new RegExp('^' + servedPathname), '')
|
|
243
|
-
)
|
|
218
|
+
const maybePublicPath = path.resolve(appPublicFolder, pathname.replace(new RegExp('^' + servedPathname), ''))
|
|
244
219
|
const isPublicFileRequest = fs.existsSync(maybePublicPath)
|
|
245
220
|
// used by webpackHotDevClient
|
|
246
|
-
const isWdsEndpointRequest =
|
|
247
|
-
isDefaultSockHost && pathname.startsWith(sockPath)
|
|
221
|
+
const isWdsEndpointRequest = isDefaultSockHost && pathname.startsWith(sockPath)
|
|
248
222
|
return !(isPublicFileRequest || isWdsEndpointRequest)
|
|
249
223
|
}
|
|
250
224
|
|
|
251
225
|
if (!/^http(s)?:\/\//.test(proxy)) {
|
|
252
|
-
console.log(
|
|
253
|
-
red(
|
|
254
|
-
'When "proxy" is specified in package.json it must start with either http:// or https://'
|
|
255
|
-
)
|
|
256
|
-
)
|
|
226
|
+
console.log(red('When "proxy" is specified in package.json it must start with either http:// or https://'))
|
|
257
227
|
process.exit(1)
|
|
258
228
|
}
|
|
259
229
|
|
|
@@ -276,9 +246,7 @@ function prepareProxy(proxy, appPublicFolder, servedPathname) {
|
|
|
276
246
|
context: function (pathname, req) {
|
|
277
247
|
return (
|
|
278
248
|
req.method !== 'GET' ||
|
|
279
|
-
(mayProxy(pathname) &&
|
|
280
|
-
req.headers.accept &&
|
|
281
|
-
req.headers.accept.indexOf('text/html') === -1)
|
|
249
|
+
(mayProxy(pathname) && req.headers.accept && req.headers.accept.indexOf('text/html') === -1)
|
|
282
250
|
)
|
|
283
251
|
},
|
|
284
252
|
onProxyReq: proxyReq => {
|
package/utils/clearConsole.js
CHANGED
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
function clearConsole() {
|
|
9
|
-
process.stdout.write(
|
|
10
|
-
process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H'
|
|
11
|
-
)
|
|
9
|
+
process.stdout.write(process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H')
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
module.exports = clearConsole
|
|
@@ -34,9 +34,7 @@ function formatMessage(message) {
|
|
|
34
34
|
// Transform parsing error into syntax error
|
|
35
35
|
// TODO: move this to our ESLint formatter?
|
|
36
36
|
lines = lines.map(line => {
|
|
37
|
-
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
|
|
38
|
-
line
|
|
39
|
-
)
|
|
37
|
+
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line)
|
|
40
38
|
if (!parsingError) {
|
|
41
39
|
return line
|
|
42
40
|
}
|
|
@@ -46,10 +44,7 @@ function formatMessage(message) {
|
|
|
46
44
|
|
|
47
45
|
message = lines.join('\n')
|
|
48
46
|
// Smoosh syntax errors (commonly found in CSS)
|
|
49
|
-
message = message.replace(
|
|
50
|
-
/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
|
|
51
|
-
`${friendlySyntaxErrorLabel} $3 ($1:$2)\n`
|
|
52
|
-
)
|
|
47
|
+
message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, `${friendlySyntaxErrorLabel} $3 ($1:$2)\n`)
|
|
53
48
|
// Clean up export errors
|
|
54
49
|
message = message.replace(
|
|
55
50
|
/^.*export '(.+?)' was not found in '(.+?)'.*$/gm,
|
|
@@ -76,17 +71,14 @@ function formatMessage(message) {
|
|
|
76
71
|
if (lines[1] && lines[1].indexOf('Module not found: ') === 0) {
|
|
77
72
|
lines = [
|
|
78
73
|
lines[0],
|
|
79
|
-
lines[1]
|
|
80
|
-
.replace('Error: ', '')
|
|
81
|
-
.replace('Module not found: Cannot find file:', 'Cannot find file:')
|
|
74
|
+
lines[1].replace('Error: ', '').replace('Module not found: Cannot find file:', 'Cannot find file:')
|
|
82
75
|
]
|
|
83
76
|
}
|
|
84
77
|
|
|
85
78
|
// Add helpful message for users trying to use Sass for the first time
|
|
86
79
|
if (lines[1] && lines[1].match(/Cannot find module.+sass/)) {
|
|
87
80
|
lines[1] = 'To import Sass files, you first need to install sass.\n'
|
|
88
|
-
lines[1] +=
|
|
89
|
-
'Run `npm install sass` or `yarn add sass` inside your workspace.'
|
|
81
|
+
lines[1] += 'Run `npm install sass` or `yarn add sass` inside your workspace.'
|
|
90
82
|
}
|
|
91
83
|
|
|
92
84
|
message = lines.join('\n')
|
|
@@ -94,18 +86,12 @@ function formatMessage(message) {
|
|
|
94
86
|
// exception of stacks containing `webpack:` because they're normally
|
|
95
87
|
// from user code generated by webpack. For more information see
|
|
96
88
|
// https://github.com/facebook/create-react-app/pull/1050
|
|
97
|
-
message = message.replace(
|
|
98
|
-
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
|
|
99
|
-
''
|
|
100
|
-
) // at ... ...:x:y
|
|
89
|
+
message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, '') // at ... ...:x:y
|
|
101
90
|
message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, '') // at <anonymous>
|
|
102
91
|
lines = message.split('\n')
|
|
103
92
|
|
|
104
93
|
// Remove duplicated newlines
|
|
105
|
-
lines = lines.filter(
|
|
106
|
-
(line, index, arr) =>
|
|
107
|
-
index === 0 || line.trim() !== '' || line.trim() !== arr[index - 1].trim()
|
|
108
|
-
)
|
|
94
|
+
lines = lines.filter((line, index, arr) => index === 0 || line.trim() !== '' || line.trim() !== arr[index - 1].trim())
|
|
109
95
|
|
|
110
96
|
// Reassemble the message
|
|
111
97
|
message = lines.join('\n')
|
|
@@ -21,11 +21,7 @@ const execOptions = {
|
|
|
21
21
|
* @returns {string} The process id
|
|
22
22
|
*/
|
|
23
23
|
function getProcessIdOnPort(port) {
|
|
24
|
-
return execFileSync(
|
|
25
|
-
'lsof',
|
|
26
|
-
[`-i:${port}`, '-P', '-t', '-sTCP:LISTEN'],
|
|
27
|
-
execOptions
|
|
28
|
-
)
|
|
24
|
+
return execFileSync('lsof', [`-i:${port}`, '-P', '-t', '-sTCP:LISTEN'], execOptions)
|
|
29
25
|
.split('\n')[0]
|
|
30
26
|
.trim()
|
|
31
27
|
}
|
|
@@ -36,10 +32,7 @@ function getProcessIdOnPort(port) {
|
|
|
36
32
|
* @returns {string} - The process name
|
|
37
33
|
*/
|
|
38
34
|
function getProcessCommand(processId) {
|
|
39
|
-
const command = execSync(
|
|
40
|
-
'ps -o command -p ' + processId + ' | sed -n 2p',
|
|
41
|
-
execOptions
|
|
42
|
-
)
|
|
35
|
+
const command = execSync('ps -o command -p ' + processId + ' | sed -n 2p', execOptions)
|
|
43
36
|
|
|
44
37
|
return command.replace(/\n$/, '')
|
|
45
38
|
}
|
|
@@ -50,10 +43,7 @@ function getProcessCommand(processId) {
|
|
|
50
43
|
* @returns {string} - The process directory
|
|
51
44
|
*/
|
|
52
45
|
function getDirectoryOfProcessById(processId) {
|
|
53
|
-
return execSync(
|
|
54
|
-
`lsof -p ${processId} | awk '$4=="cwd" {for (i=9; i<=NF; i++) printf "%s ", $i}'`,
|
|
55
|
-
execOptions
|
|
56
|
-
).trim()
|
|
46
|
+
return execSync(`lsof -p ${processId} | awk '$4=="cwd" {for (i=9; i<=NF; i++) printf "%s ", $i}'`, execOptions).trim()
|
|
57
47
|
}
|
|
58
48
|
|
|
59
49
|
/**
|
|
@@ -67,12 +57,7 @@ function getProcessForPort(port) {
|
|
|
67
57
|
const directory = getDirectoryOfProcessById(processId)
|
|
68
58
|
const command = getProcessCommand(processId)
|
|
69
59
|
|
|
70
|
-
return (
|
|
71
|
-
bold(command) +
|
|
72
|
-
gray(' (pid ' + processId + ')\n') +
|
|
73
|
-
gray(' in ') +
|
|
74
|
-
cyan(directory)
|
|
75
|
-
)
|
|
60
|
+
return bold(command) + gray(' (pid ' + processId + ')\n') + gray(' in ') + cyan(directory)
|
|
76
61
|
} catch (e) {
|
|
77
62
|
return null
|
|
78
63
|
}
|
package/utils/ignoredFiles.js
CHANGED
|
@@ -13,10 +13,5 @@ const path = require('path')
|
|
|
13
13
|
const escape = require('escape-string-regexp')
|
|
14
14
|
|
|
15
15
|
module.exports = function ignoredFiles(appSrc) {
|
|
16
|
-
return new RegExp(
|
|
17
|
-
`^(?!${escape(
|
|
18
|
-
path.normalize(appSrc + '/').replace(/[\\]+/g, '/')
|
|
19
|
-
)}).+/node_modules/`,
|
|
20
|
-
'g'
|
|
21
|
-
)
|
|
16
|
+
return new RegExp(`^(?!${escape(path.normalize(appSrc + '/').replace(/[\\]+/g, '/'))}).+/node_modules/`, 'g')
|
|
22
17
|
}
|
package/webpack.config.dev.js
CHANGED
|
@@ -5,13 +5,7 @@ const webpack = require('webpack')
|
|
|
5
5
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
6
6
|
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
|
|
7
7
|
|
|
8
|
-
const {
|
|
9
|
-
envVars,
|
|
10
|
-
MAIN_ENTRY_POINT,
|
|
11
|
-
config,
|
|
12
|
-
cleanList,
|
|
13
|
-
when
|
|
14
|
-
} = require('./shared/index.js')
|
|
8
|
+
const {envVars, MAIN_ENTRY_POINT, config, cleanList, when} = require('./shared/index.js')
|
|
15
9
|
const definePlugin = require('./shared/define.js')
|
|
16
10
|
const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js')
|
|
17
11
|
const {aliasFromConfig, defaultAlias} = require('./shared/resolve-alias.js')
|
|
@@ -114,14 +108,11 @@ const webpackConfig = {
|
|
|
114
108
|
require.resolve('@s-ui/sass-loader')
|
|
115
109
|
])
|
|
116
110
|
},
|
|
117
|
-
when(config['externals-manifest'], () =>
|
|
118
|
-
manifestLoaderRules(config['externals-manifest'])
|
|
119
|
-
)
|
|
111
|
+
when(config['externals-manifest'], () => manifestLoaderRules(config['externals-manifest']))
|
|
120
112
|
])
|
|
121
113
|
},
|
|
122
114
|
watch: !CI,
|
|
123
|
-
devtool:
|
|
124
|
-
config.sourcemaps && config.sourcemaps.dev ? config.sourcemaps.dev : false
|
|
115
|
+
devtool: config.sourcemaps && config.sourcemaps.dev ? config.sourcemaps.dev : false
|
|
125
116
|
}
|
|
126
117
|
|
|
127
118
|
module.exports = webpackConfig
|
package/webpack.config.lib.js
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
const webpack = require('webpack')
|
|
2
2
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
3
|
-
const {
|
|
4
|
-
cleanList,
|
|
5
|
-
envVars,
|
|
6
|
-
MAIN_ENTRY_POINT,
|
|
7
|
-
config
|
|
8
|
-
} = require('./shared/index.js')
|
|
3
|
+
const {cleanList, envVars, MAIN_ENTRY_POINT, config} = require('./shared/index.js')
|
|
9
4
|
const path = require('path')
|
|
10
5
|
const minifyJs = require('./shared/minify-js.js')
|
|
11
6
|
const definePlugin = require('./shared/define.js')
|
|
12
7
|
const createBabelRules = require('./shared/module-rules-babel.js')
|
|
13
8
|
const sassRules = require('./shared/module-rules-sass.js')
|
|
14
|
-
const {
|
|
15
|
-
extractComments,
|
|
16
|
-
sourceMap,
|
|
17
|
-
supportLegacyBrowsers
|
|
18
|
-
} = require('./shared/config.js')
|
|
9
|
+
const {extractComments, sourceMap, supportLegacyBrowsers} = require('./shared/config.js')
|
|
19
10
|
const {aliasFromConfig} = require('./shared/resolve-alias.js')
|
|
20
11
|
|
|
21
12
|
const cssFileName = 'styles.css'
|
package/webpack.config.prod.js
CHANGED
|
@@ -9,19 +9,9 @@ const {WebpackManifestPlugin} = require('webpack-manifest-plugin')
|
|
|
9
9
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
10
10
|
const InlineChunkHtmlPlugin = require('./shared/inline-chunk-html-plugin.js')
|
|
11
11
|
|
|
12
|
-
const {
|
|
13
|
-
when,
|
|
14
|
-
cleanList,
|
|
15
|
-
envVars,
|
|
16
|
-
MAIN_ENTRY_POINT,
|
|
17
|
-
config
|
|
18
|
-
} = require('./shared/index.js')
|
|
12
|
+
const {when, cleanList, envVars, MAIN_ENTRY_POINT, config} = require('./shared/index.js')
|
|
19
13
|
const {aliasFromConfig} = require('./shared/resolve-alias.js')
|
|
20
|
-
const {
|
|
21
|
-
extractComments,
|
|
22
|
-
sourceMap,
|
|
23
|
-
supportLegacyBrowsers
|
|
24
|
-
} = require('./shared/config.js')
|
|
14
|
+
const {extractComments, sourceMap, supportLegacyBrowsers} = require('./shared/config.js')
|
|
25
15
|
const {resolveLoader} = require('./shared/resolve-loader.js')
|
|
26
16
|
const createBabelRules = require('./shared/module-rules-babel.js')
|
|
27
17
|
const sassRules = require('./shared/module-rules-sass.js')
|
|
@@ -34,13 +24,9 @@ const CWD = process.cwd()
|
|
|
34
24
|
const PUBLIC_PATH = process.env.CDN || config.cdn || '/'
|
|
35
25
|
const PWD = process.env.PWD ?? ''
|
|
36
26
|
|
|
37
|
-
const filename = config.onlyHash
|
|
38
|
-
? '[contenthash:8].js'
|
|
39
|
-
: '[name].[contenthash:8].js'
|
|
27
|
+
const filename = config.onlyHash ? '[contenthash:8].js' : '[name].[contenthash:8].js'
|
|
40
28
|
|
|
41
|
-
const cssFileName = config.onlyHash
|
|
42
|
-
? '[contenthash:8].css'
|
|
43
|
-
: '[name].[contenthash:8].css'
|
|
29
|
+
const cssFileName = config.onlyHash ? '[contenthash:8].css' : '[name].[contenthash:8].css'
|
|
44
30
|
|
|
45
31
|
const target = supportLegacyBrowsers ? ['web', 'es5'] : 'web'
|
|
46
32
|
|
|
@@ -77,9 +63,7 @@ const webpackConfig = {
|
|
|
77
63
|
optimization: {
|
|
78
64
|
checkWasmTypes: false,
|
|
79
65
|
minimize: true,
|
|
80
|
-
minimizer: [minifyJs({extractComments, sourceMap}), minifyCss()].filter(
|
|
81
|
-
Boolean
|
|
82
|
-
),
|
|
66
|
+
minimizer: [minifyJs({extractComments, sourceMap}), minifyCss()].filter(Boolean),
|
|
83
67
|
runtimeChunk: true
|
|
84
68
|
},
|
|
85
69
|
plugins: cleanList([
|
|
@@ -116,9 +100,7 @@ const webpackConfig = {
|
|
|
116
100
|
rules: cleanList([
|
|
117
101
|
createBabelRules({supportLegacyBrowsers}),
|
|
118
102
|
sassRules,
|
|
119
|
-
when(config['externals-manifest'], () =>
|
|
120
|
-
manifestLoaderRules(config['externals-manifest'])
|
|
121
|
-
)
|
|
103
|
+
when(config['externals-manifest'], () => manifestLoaderRules(config['externals-manifest']))
|
|
122
104
|
])
|
|
123
105
|
},
|
|
124
106
|
resolveLoader
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const webpack = require('webpack')
|
|
5
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
6
|
+
const {WebpackManifestPlugin} = require('webpack-manifest-plugin')
|
|
7
|
+
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
|
|
8
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
9
|
+
|
|
10
|
+
const {envVars, MAIN_ENTRY_POINT, config, cleanList, when} = require('./shared/index.js')
|
|
11
|
+
const definePlugin = require('./shared/define.js')
|
|
12
|
+
const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js')
|
|
13
|
+
const {aliasFromConfig, defaultAlias} = require('./shared/resolve-alias.js')
|
|
14
|
+
const {supportLegacyBrowsers} = require('./shared/config.js')
|
|
15
|
+
|
|
16
|
+
const {resolveLoader} = require('./shared/resolve-loader.js')
|
|
17
|
+
const createBabelRules = require('./shared/module-rules-babel.js')
|
|
18
|
+
|
|
19
|
+
const outputPath = path.join(process.cwd(), '.sui/public')
|
|
20
|
+
|
|
21
|
+
const {CI = false, PWD = '', CDN} = process.env
|
|
22
|
+
|
|
23
|
+
process.env.NODE_ENV = 'development'
|
|
24
|
+
|
|
25
|
+
/** @typedef {import('webpack').Configuration} WebpackConfig */
|
|
26
|
+
|
|
27
|
+
const webpackConfig = {
|
|
28
|
+
mode: 'development',
|
|
29
|
+
context: path.resolve(PWD, 'src'),
|
|
30
|
+
resolve: {
|
|
31
|
+
alias: {
|
|
32
|
+
...defaultAlias,
|
|
33
|
+
...aliasFromConfig
|
|
34
|
+
},
|
|
35
|
+
fallback: {
|
|
36
|
+
fs: false,
|
|
37
|
+
http: require.resolve('stream-http'),
|
|
38
|
+
https: require.resolve('https-browserify'),
|
|
39
|
+
buffer: require.resolve('buffer/'),
|
|
40
|
+
url: require.resolve('url/'),
|
|
41
|
+
stream: false,
|
|
42
|
+
zlib: false,
|
|
43
|
+
timers: false
|
|
44
|
+
},
|
|
45
|
+
modules: ['node_modules', path.resolve(process.cwd())],
|
|
46
|
+
extensions: ['.js', '.json']
|
|
47
|
+
},
|
|
48
|
+
stats: 'errors-only',
|
|
49
|
+
entry: {
|
|
50
|
+
app: [`webpack-hot-middleware/client?path=${CDN}__webpack_hmr`, MAIN_ENTRY_POINT]
|
|
51
|
+
},
|
|
52
|
+
target: 'web',
|
|
53
|
+
optimization: {
|
|
54
|
+
checkWasmTypes: false,
|
|
55
|
+
emitOnErrors: false,
|
|
56
|
+
removeAvailableModules: false,
|
|
57
|
+
removeEmptyChunks: false,
|
|
58
|
+
runtimeChunk: true,
|
|
59
|
+
splitChunks: false
|
|
60
|
+
},
|
|
61
|
+
output: {
|
|
62
|
+
path: outputPath,
|
|
63
|
+
pathinfo: false,
|
|
64
|
+
publicPath: CDN
|
|
65
|
+
},
|
|
66
|
+
plugins: [
|
|
67
|
+
new webpack.ProvidePlugin({
|
|
68
|
+
process: 'process/browser.js'
|
|
69
|
+
}),
|
|
70
|
+
new webpack.EnvironmentPlugin(envVars(config.env)),
|
|
71
|
+
definePlugin({__DEV__: true}),
|
|
72
|
+
new MiniCssExtractPlugin(),
|
|
73
|
+
new HtmlWebpackPlugin({
|
|
74
|
+
template: './index.html',
|
|
75
|
+
inject: true,
|
|
76
|
+
env: process.env
|
|
77
|
+
}),
|
|
78
|
+
new WebpackManifestPlugin({fileName: 'asset-manifest.json'}),
|
|
79
|
+
new webpack.HotModuleReplacementPlugin(),
|
|
80
|
+
new ReactRefreshWebpackPlugin({overlay: false})
|
|
81
|
+
],
|
|
82
|
+
resolveLoader,
|
|
83
|
+
module: {
|
|
84
|
+
rules: cleanList([
|
|
85
|
+
createBabelRules({supportLegacyBrowsers, isDevelopment: true}),
|
|
86
|
+
{
|
|
87
|
+
test: /(\.css|\.scss)$/,
|
|
88
|
+
use: cleanList([
|
|
89
|
+
MiniCssExtractPlugin.loader,
|
|
90
|
+
require.resolve('css-loader'),
|
|
91
|
+
when(config['externals-manifest'], () => ({
|
|
92
|
+
loader: 'externals-manifest-loader',
|
|
93
|
+
options: {
|
|
94
|
+
manifestURL: config['externals-manifest']
|
|
95
|
+
}
|
|
96
|
+
})),
|
|
97
|
+
{
|
|
98
|
+
loader: require.resolve('postcss-loader'),
|
|
99
|
+
options: {
|
|
100
|
+
postcssOptions: {
|
|
101
|
+
plugins: [
|
|
102
|
+
require('autoprefixer')({
|
|
103
|
+
overrideBrowserslist: config.targets
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
require.resolve('@s-ui/sass-loader')
|
|
110
|
+
])
|
|
111
|
+
},
|
|
112
|
+
when(config['externals-manifest'], () => manifestLoaderRules(config['externals-manifest']))
|
|
113
|
+
])
|
|
114
|
+
},
|
|
115
|
+
watch: !CI,
|
|
116
|
+
devtool: config.sourcemaps && config.sourcemaps.dev ? config.sourcemaps.dev : false
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = webpackConfig
|
package/webpack.config.server.js
CHANGED
|
@@ -48,9 +48,7 @@ const webpackConfig = {
|
|
|
48
48
|
dataUrl: () => ''
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
-
when(config['externals-manifest'], () =>
|
|
52
|
-
manifestLoaderRules(config['externals-manifest'])
|
|
53
|
-
)
|
|
51
|
+
when(config['externals-manifest'], () => manifestLoaderRules(config['externals-manifest']))
|
|
54
52
|
])
|
|
55
53
|
}
|
|
56
54
|
}
|