@s-ui/bundler 9.55.0 → 9.56.0-beta.1
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-lib.js +3 -2
- package/package.json +1 -1
- package/shared/define.js +1 -0
- package/webpack.config.lib.js +58 -48
package/bin/sui-bundler-lib.js
CHANGED
|
@@ -17,6 +17,7 @@ program
|
|
|
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
19
|
.option('-p, --path [path]', 'Absolute public path where files will be located.')
|
|
20
|
+
.option('--chunk-css', 'Bundle css in chunks')
|
|
20
21
|
.on('--help', () =>
|
|
21
22
|
console.log(`Examples:
|
|
22
23
|
$ sui-bundler lib src/index.js -o umd/my-lib -p http://my-cdn.com/my-lib -C'
|
|
@@ -27,7 +28,7 @@ program
|
|
|
27
28
|
|
|
28
29
|
const [entry] = program.args
|
|
29
30
|
const options = program.opts()
|
|
30
|
-
const {clean = false, output, umd = false, root = false} = options
|
|
31
|
+
const {clean = false, output, umd = false, root = false, chunkCss = false} = options
|
|
31
32
|
const publicPath = options.path
|
|
32
33
|
|
|
33
34
|
if (!output) {
|
|
@@ -46,7 +47,7 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
|
|
46
47
|
|
|
47
48
|
const version = getPackageJson(process.cwd()).version
|
|
48
49
|
const outputFolder = path.join(process.cwd(), output, path.sep, root ? '' : version)
|
|
49
|
-
const webpackConfig = {...config, entry: path.resolve(process.cwd(), entry)}
|
|
50
|
+
const webpackConfig = {...config({chunkCss}), entry: path.resolve(process.cwd(), entry)}
|
|
50
51
|
webpackConfig.output.publicPath = publicPath + (root ? '' : version + '/')
|
|
51
52
|
webpackConfig.output.path = outputFolder
|
|
52
53
|
|
package/package.json
CHANGED
package/shared/define.js
CHANGED
|
@@ -8,6 +8,7 @@ if (process.platform === 'win32') {
|
|
|
8
8
|
|
|
9
9
|
module.exports = (vars = {}) =>
|
|
10
10
|
new webpack.DefinePlugin({
|
|
11
|
+
__MOCKS_API_PATH__: JSON.stringify(process.env.MOCKS_API_PATH || process.env.PWD + '/mocks/routes'),
|
|
11
12
|
__DEV__: false,
|
|
12
13
|
__BASE_DIR__: JSON.stringify(process.env.PWD),
|
|
13
14
|
...vars
|
package/webpack.config.lib.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const webpack = require('webpack')
|
|
2
2
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
cleanList,
|
|
5
|
+
envVars,
|
|
6
|
+
MAIN_ENTRY_POINT,
|
|
7
|
+
config
|
|
8
|
+
} = require('./shared/index.js')
|
|
4
9
|
const path = require('path')
|
|
5
10
|
const minifyJs = require('./shared/minify-js.js')
|
|
6
11
|
const definePlugin = require('./shared/define.js')
|
|
@@ -9,55 +14,60 @@ const sassRules = require('./shared/module-rules-sass.js')
|
|
|
9
14
|
const {extractComments, sourceMap, supportLegacyBrowsers} = require('./shared/config.js')
|
|
10
15
|
const {aliasFromConfig} = require('./shared/resolve-alias.js')
|
|
11
16
|
|
|
12
|
-
const cssFileName = 'styles.css'
|
|
13
17
|
|
|
14
|
-
module.exports = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
module.exports = ({
|
|
19
|
+
chunkCss
|
|
20
|
+
} = {}) => {
|
|
21
|
+
const chunkCssName = config.onlyHash ? '[contenthash:8].css' : '[name].[contenthash:8].css'
|
|
22
|
+
const cssFileName = chunkCss ? chunkCssName : 'styles.css'
|
|
23
|
+
return {
|
|
24
|
+
mode: 'production',
|
|
25
|
+
resolve: {
|
|
26
|
+
alias: {
|
|
27
|
+
...aliasFromConfig
|
|
28
|
+
},
|
|
29
|
+
fallback: {
|
|
30
|
+
assert: false,
|
|
31
|
+
fs: false,
|
|
32
|
+
http: require.resolve('stream-http'),
|
|
33
|
+
https: require.resolve('https-browserify'),
|
|
34
|
+
path: false
|
|
35
|
+
},
|
|
36
|
+
extensions: ['.js', '.json'],
|
|
37
|
+
modules: ['node_modules', path.resolve(process.cwd())]
|
|
19
38
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
fs: false,
|
|
23
|
-
http: require.resolve('stream-http'),
|
|
24
|
-
https: require.resolve('https-browserify'),
|
|
25
|
-
path: false
|
|
26
|
-
},
|
|
27
|
-
extensions: ['.js', '.json'],
|
|
28
|
-
modules: ['node_modules', path.resolve(process.cwd())]
|
|
29
|
-
},
|
|
30
|
-
entry: config.vendor
|
|
31
|
-
? {
|
|
39
|
+
entry: config.vendor ?
|
|
40
|
+
{
|
|
32
41
|
app: MAIN_ENTRY_POINT,
|
|
33
42
|
vendor: config.vendor
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
43
|
+
} :
|
|
44
|
+
MAIN_ENTRY_POINT,
|
|
45
|
+
target: 'web',
|
|
46
|
+
output: {
|
|
47
|
+
filename: 'index.js'
|
|
48
|
+
},
|
|
49
|
+
optimization: {
|
|
50
|
+
// avoid looping over all the modules after the compilation
|
|
51
|
+
checkWasmTypes: false,
|
|
52
|
+
minimize: true,
|
|
53
|
+
minimizer: [minifyJs({extractComments, sourceMap})]
|
|
54
|
+
},
|
|
55
|
+
plugins: cleanList([
|
|
56
|
+
new webpack.ProvidePlugin({
|
|
57
|
+
process: 'process/browser'
|
|
58
|
+
}),
|
|
59
|
+
new MiniCssExtractPlugin({
|
|
60
|
+
filename: cssFileName,
|
|
61
|
+
chunkFilename: cssFileName
|
|
62
|
+
}),
|
|
63
|
+
!chunkCss && new webpack.optimize.LimitChunkCountPlugin({
|
|
64
|
+
maxChunks: 1
|
|
65
|
+
}),
|
|
66
|
+
new webpack.EnvironmentPlugin(envVars(config.env)),
|
|
67
|
+
definePlugin()
|
|
68
|
+
]),
|
|
69
|
+
module: {
|
|
70
|
+
rules: [createBabelRules({supportLegacyBrowsers}), sassRules]
|
|
71
|
+
}
|
|
62
72
|
}
|
|
63
|
-
}
|
|
73
|
+
}
|