@autobest-ui/scripts 0.0.3 → 0.1.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/README.md +120 -1
- package/bin/spa.js +44 -44
- package/bin/ssr.js +44 -44
- package/common/appConfig.js +11 -11
- package/common/build.js +40 -40
- package/common/extendEnv.js +49 -48
- package/common/formatWebpackMessages.js +97 -97
- package/common/getCSSModuleLocalIdent.js +14 -14
- package/common/start.js +71 -71
- package/common/utils.js +64 -59
- package/common/version.js +23 -23
- package/common/webpack.common.js +218 -162
- package/package.json +20 -2
- package/spaConfig/build.js +65 -65
- package/spaConfig/start.js +4 -4
- package/spaConfig/webpack.base.js +28 -28
- package/spaConfig/webpack.dev.js +45 -45
- package/spaConfig/webpack.prod.js +78 -78
- package/ssrConfig/build.js +82 -82
- package/ssrConfig/server.js +144 -144
- package/ssrConfig/start.js +4 -4
- package/ssrConfig/webpack.base.js +46 -60
- package/ssrConfig/webpack.dev.client.js +31 -31
- package/ssrConfig/webpack.dev.js +58 -58
- package/ssrConfig/webpack.dev.server.js +58 -58
- package/ssrConfig/webpack.prod.client.js +92 -92
- package/ssrConfig/webpack.prod.server.js +50 -50
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
const webpack = require('webpack');
|
|
2
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
|
-
const nodeExternals = require('webpack-node-externals');
|
|
4
|
-
const merge = require('webpack-merge');
|
|
5
|
-
const baseConfig = require('./webpack.base');
|
|
6
|
-
const { getProjectPath } = require('../common/utils');
|
|
7
|
-
|
|
8
|
-
module.exports = function(appConfig, extendEnv) {
|
|
9
|
-
return merge(
|
|
10
|
-
baseConfig(appConfig, extendEnv, {
|
|
11
|
-
isServer: true,
|
|
12
|
-
isHotServer: true,
|
|
13
|
-
isSetCommonAlias: true,
|
|
14
|
-
isProd: false
|
|
15
|
-
}),
|
|
16
|
-
{
|
|
17
|
-
// 告诉 webpack打包的是 node端代码,避免把nodejs内置的模块打包到输出文件中,例如 fs path
|
|
18
|
-
target: 'node',
|
|
19
|
-
// 避免把 node_modules包下的第三方模块中包含的 nodejs内置的模块打包到出书文件中
|
|
20
|
-
externals: nodeExternals({
|
|
21
|
-
// 当然外部的css还是可以打进来的
|
|
22
|
-
whitelist: /\.(js|css|less|scss|png|jpg|jpeg)$/
|
|
23
|
-
}),
|
|
24
|
-
// 入口文件
|
|
25
|
-
entry: getProjectPath(appConfig.hotSsrServerEntry),
|
|
26
|
-
// 输出信息
|
|
27
|
-
output: {
|
|
28
|
-
path: getProjectPath(appConfig.hotSsrServerOutput.path),
|
|
29
|
-
publicPath: appConfig.hotSsrServerOutput.publicPath || '/',
|
|
30
|
-
// 输出文件名
|
|
31
|
-
filename: 'bundle.js',
|
|
32
|
-
libraryTarget: 'commonjs2'
|
|
33
|
-
},
|
|
34
|
-
module: {
|
|
35
|
-
rules: [
|
|
36
|
-
{
|
|
37
|
-
oneOf: [
|
|
38
|
-
{
|
|
39
|
-
test: /\.(scss|css|sass)$/,
|
|
40
|
-
use: [
|
|
41
|
-
{
|
|
42
|
-
loader: 'ignore-loader'
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
},
|
|
50
|
-
plugins: [new webpack.ContextReplacementPlugin(/any-promise/)],
|
|
51
|
-
// 避免路径丢失
|
|
52
|
-
node: {
|
|
53
|
-
__filename: true,
|
|
54
|
-
__dirname: true
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
};
|
|
1
|
+
const webpack = require('webpack');
|
|
2
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
|
+
const nodeExternals = require('webpack-node-externals');
|
|
4
|
+
const merge = require('webpack-merge');
|
|
5
|
+
const baseConfig = require('./webpack.base');
|
|
6
|
+
const { getProjectPath } = require('../common/utils');
|
|
7
|
+
|
|
8
|
+
module.exports = function(appConfig, extendEnv) {
|
|
9
|
+
return merge(
|
|
10
|
+
baseConfig(appConfig, extendEnv, {
|
|
11
|
+
isServer: true,
|
|
12
|
+
isHotServer: true,
|
|
13
|
+
isSetCommonAlias: true,
|
|
14
|
+
isProd: false
|
|
15
|
+
}),
|
|
16
|
+
{
|
|
17
|
+
// 告诉 webpack打包的是 node端代码,避免把nodejs内置的模块打包到输出文件中,例如 fs path
|
|
18
|
+
target: 'node',
|
|
19
|
+
// 避免把 node_modules包下的第三方模块中包含的 nodejs内置的模块打包到出书文件中
|
|
20
|
+
externals: nodeExternals({
|
|
21
|
+
// 当然外部的css还是可以打进来的
|
|
22
|
+
whitelist: /\.(js|css|less|scss|png|jpg|jpeg)$/
|
|
23
|
+
}),
|
|
24
|
+
// 入口文件
|
|
25
|
+
entry: getProjectPath(appConfig.hotSsrServerEntry),
|
|
26
|
+
// 输出信息
|
|
27
|
+
output: {
|
|
28
|
+
path: getProjectPath(appConfig.hotSsrServerOutput.path),
|
|
29
|
+
publicPath: appConfig.hotSsrServerOutput.publicPath || '/',
|
|
30
|
+
// 输出文件名
|
|
31
|
+
filename: 'bundle.js',
|
|
32
|
+
libraryTarget: 'commonjs2'
|
|
33
|
+
},
|
|
34
|
+
module: {
|
|
35
|
+
rules: [
|
|
36
|
+
{
|
|
37
|
+
oneOf: [
|
|
38
|
+
{
|
|
39
|
+
test: /\.(scss|css|sass)$/,
|
|
40
|
+
use: [
|
|
41
|
+
{
|
|
42
|
+
loader: 'ignore-loader'
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
plugins: [new webpack.ContextReplacementPlugin(/any-promise/)],
|
|
51
|
+
// 避免路径丢失
|
|
52
|
+
node: {
|
|
53
|
+
__filename: true,
|
|
54
|
+
__dirname: true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
};
|
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
const merge = require('webpack-merge');
|
|
2
|
-
const LoadablePlugin = require('@loadable/webpack-plugin');
|
|
3
|
-
const TerserPlugin = require('terser-webpack-plugin');
|
|
4
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
5
|
-
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
6
|
-
const safePostCssParser = require('postcss-safe-parser');
|
|
7
|
-
const baseConfig = require('./webpack.base');
|
|
8
|
-
|
|
9
|
-
const { getProjectPath } = require('../common/utils');
|
|
10
|
-
|
|
11
|
-
const isCommonBuild = process.env.REACT_APP_BUILD_TYPE === 'common';
|
|
12
|
-
|
|
13
|
-
module.exports = function(appConfig, extendEnv) {
|
|
14
|
-
return merge(
|
|
15
|
-
baseConfig(appConfig, extendEnv, {
|
|
16
|
-
isServer: false,
|
|
17
|
-
isHotServer: false,
|
|
18
|
-
isSetCommonAlias: isCommonBuild,
|
|
19
|
-
isProd: true
|
|
20
|
-
}),
|
|
21
|
-
{
|
|
22
|
-
entry: getProjectPath(appConfig.buildClientEntry),
|
|
23
|
-
// 打包的出口
|
|
24
|
-
output: {
|
|
25
|
-
path: getProjectPath(appConfig.buildClientOutput.path),
|
|
26
|
-
publicPath: appConfig.buildClientOutput.publicPath || '/',
|
|
27
|
-
// 入口文件生产的js
|
|
28
|
-
filename: `js/[name].js?v=${extendEnv.version}`,
|
|
29
|
-
// 非入口文件生产的js
|
|
30
|
-
chunkFilename: `js/[name].js?v=${extendEnv.version}`
|
|
31
|
-
},
|
|
32
|
-
node: {
|
|
33
|
-
fs: 'empty'
|
|
34
|
-
},
|
|
35
|
-
plugins: [
|
|
36
|
-
new LoadablePlugin({
|
|
37
|
-
filename: appConfig.buildClientLoadableConfig.filename,
|
|
38
|
-
writeToDisk: {
|
|
39
|
-
filename: getProjectPath(appConfig.buildClientLoadableConfig.writeToDiskFilename)
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
],
|
|
43
|
-
optimization: {
|
|
44
|
-
minimizer: [
|
|
45
|
-
// 压缩js
|
|
46
|
-
new TerserPlugin({
|
|
47
|
-
cache: true,
|
|
48
|
-
parallel: true,
|
|
49
|
-
sourceMap: true
|
|
50
|
-
}),
|
|
51
|
-
|
|
52
|
-
// 压缩css
|
|
53
|
-
new OptimizeCSSAssetsPlugin({
|
|
54
|
-
cssProcessorOptions: {
|
|
55
|
-
parser: safePostCssParser,
|
|
56
|
-
map: {
|
|
57
|
-
inline: false,
|
|
58
|
-
annotation: false
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
],
|
|
63
|
-
splitChunks: {
|
|
64
|
-
chunks: 'initial',
|
|
65
|
-
minSize: 0,
|
|
66
|
-
maxAsyncRequests: 5,
|
|
67
|
-
maxInitialRequests: 3,
|
|
68
|
-
automaticNameDelimiter: '~',
|
|
69
|
-
name: true,
|
|
70
|
-
cacheGroups: {
|
|
71
|
-
common: {
|
|
72
|
-
chunks: 'async',
|
|
73
|
-
name: 'common',
|
|
74
|
-
minChunks: 20,
|
|
75
|
-
priority: 2
|
|
76
|
-
},
|
|
77
|
-
vendor: {
|
|
78
|
-
test: /[\\/]node_modules[\\/]/,
|
|
79
|
-
chunks: 'initial',
|
|
80
|
-
name: 'vendor',
|
|
81
|
-
minChunks: 1,
|
|
82
|
-
priority: 10
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
runtimeChunk: {
|
|
87
|
-
name: 'manifest'
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
);
|
|
92
|
-
};
|
|
1
|
+
const merge = require('webpack-merge');
|
|
2
|
+
const LoadablePlugin = require('@loadable/webpack-plugin');
|
|
3
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
|
4
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
5
|
+
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
6
|
+
const safePostCssParser = require('postcss-safe-parser');
|
|
7
|
+
const baseConfig = require('./webpack.base');
|
|
8
|
+
|
|
9
|
+
const { getProjectPath } = require('../common/utils');
|
|
10
|
+
|
|
11
|
+
const isCommonBuild = process.env.REACT_APP_BUILD_TYPE === 'common';
|
|
12
|
+
|
|
13
|
+
module.exports = function(appConfig, extendEnv) {
|
|
14
|
+
return merge(
|
|
15
|
+
baseConfig(appConfig, extendEnv, {
|
|
16
|
+
isServer: false,
|
|
17
|
+
isHotServer: false,
|
|
18
|
+
isSetCommonAlias: isCommonBuild,
|
|
19
|
+
isProd: true
|
|
20
|
+
}),
|
|
21
|
+
{
|
|
22
|
+
entry: getProjectPath(appConfig.buildClientEntry),
|
|
23
|
+
// 打包的出口
|
|
24
|
+
output: {
|
|
25
|
+
path: getProjectPath(appConfig.buildClientOutput.path),
|
|
26
|
+
publicPath: appConfig.buildClientOutput.publicPath || '/',
|
|
27
|
+
// 入口文件生产的js
|
|
28
|
+
filename: `js/[name].js?v=${extendEnv.version}`,
|
|
29
|
+
// 非入口文件生产的js
|
|
30
|
+
chunkFilename: `js/[name].js?v=${extendEnv.version}`
|
|
31
|
+
},
|
|
32
|
+
node: {
|
|
33
|
+
fs: 'empty'
|
|
34
|
+
},
|
|
35
|
+
plugins: [
|
|
36
|
+
new LoadablePlugin({
|
|
37
|
+
filename: appConfig.buildClientLoadableConfig.filename,
|
|
38
|
+
writeToDisk: {
|
|
39
|
+
filename: getProjectPath(appConfig.buildClientLoadableConfig.writeToDiskFilename)
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
],
|
|
43
|
+
optimization: {
|
|
44
|
+
minimizer: [
|
|
45
|
+
// 压缩js
|
|
46
|
+
new TerserPlugin({
|
|
47
|
+
cache: true,
|
|
48
|
+
parallel: true,
|
|
49
|
+
sourceMap: true
|
|
50
|
+
}),
|
|
51
|
+
|
|
52
|
+
// 压缩css
|
|
53
|
+
new OptimizeCSSAssetsPlugin({
|
|
54
|
+
cssProcessorOptions: {
|
|
55
|
+
parser: safePostCssParser,
|
|
56
|
+
map: {
|
|
57
|
+
inline: false,
|
|
58
|
+
annotation: false
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
],
|
|
63
|
+
splitChunks: {
|
|
64
|
+
chunks: 'initial',
|
|
65
|
+
minSize: 0,
|
|
66
|
+
maxAsyncRequests: 5,
|
|
67
|
+
maxInitialRequests: 3,
|
|
68
|
+
automaticNameDelimiter: '~',
|
|
69
|
+
name: true,
|
|
70
|
+
cacheGroups: {
|
|
71
|
+
common: {
|
|
72
|
+
chunks: 'async',
|
|
73
|
+
name: 'common',
|
|
74
|
+
minChunks: 20,
|
|
75
|
+
priority: 2
|
|
76
|
+
},
|
|
77
|
+
vendor: {
|
|
78
|
+
test: /[\\/]node_modules[\\/]/,
|
|
79
|
+
chunks: 'initial',
|
|
80
|
+
name: 'vendor',
|
|
81
|
+
minChunks: 1,
|
|
82
|
+
priority: 10
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
runtimeChunk: {
|
|
87
|
+
name: 'manifest'
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
};
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
-
const nodeExternals = require('webpack-node-externals');
|
|
3
|
-
const merge = require('webpack-merge');
|
|
4
|
-
const baseConfig = require('./webpack.base');
|
|
5
|
-
const { getProjectPath } = require('../common/utils');
|
|
6
|
-
|
|
7
|
-
const isCommonBuild = process.env.REACT_APP_BUILD_TYPE === 'common';
|
|
8
|
-
|
|
9
|
-
module.exports = function(appConfig, extendEnv) {
|
|
10
|
-
return merge(
|
|
11
|
-
baseConfig(appConfig, extendEnv, {
|
|
12
|
-
isServer: true,
|
|
13
|
-
isHotServer: false,
|
|
14
|
-
isSetCommonAlias: isCommonBuild,
|
|
15
|
-
isProd: true
|
|
16
|
-
}),
|
|
17
|
-
{
|
|
18
|
-
target: 'node',
|
|
19
|
-
entry: getProjectPath(appConfig.buildServerEntry),
|
|
20
|
-
output: {
|
|
21
|
-
path: getProjectPath(appConfig.buildServerOutput.path),
|
|
22
|
-
publicPath: appConfig.buildServerOutput.publicPath || '/',
|
|
23
|
-
filename: 'server-bundle.js',
|
|
24
|
-
libraryTarget: 'commonjs2',
|
|
25
|
-
chunkFilename: 'js/[name].[chunkhash].js'
|
|
26
|
-
},
|
|
27
|
-
module: {
|
|
28
|
-
rules: [
|
|
29
|
-
{
|
|
30
|
-
oneOf: [
|
|
31
|
-
{
|
|
32
|
-
test: /\.(scss|css|sass)$/,
|
|
33
|
-
use: [
|
|
34
|
-
{
|
|
35
|
-
loader: 'ignore-loader'
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
|
-
// 服务端打包的时候忽略外部的npm包
|
|
44
|
-
externals: nodeExternals({
|
|
45
|
-
// 当然外部的css还是可以打进来的
|
|
46
|
-
whitelist: /\.(css|less|scss)$/
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
};
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
const nodeExternals = require('webpack-node-externals');
|
|
3
|
+
const merge = require('webpack-merge');
|
|
4
|
+
const baseConfig = require('./webpack.base');
|
|
5
|
+
const { getProjectPath } = require('../common/utils');
|
|
6
|
+
|
|
7
|
+
const isCommonBuild = process.env.REACT_APP_BUILD_TYPE === 'common';
|
|
8
|
+
|
|
9
|
+
module.exports = function(appConfig, extendEnv) {
|
|
10
|
+
return merge(
|
|
11
|
+
baseConfig(appConfig, extendEnv, {
|
|
12
|
+
isServer: true,
|
|
13
|
+
isHotServer: false,
|
|
14
|
+
isSetCommonAlias: isCommonBuild,
|
|
15
|
+
isProd: true
|
|
16
|
+
}),
|
|
17
|
+
{
|
|
18
|
+
target: 'node',
|
|
19
|
+
entry: getProjectPath(appConfig.buildServerEntry),
|
|
20
|
+
output: {
|
|
21
|
+
path: getProjectPath(appConfig.buildServerOutput.path),
|
|
22
|
+
publicPath: appConfig.buildServerOutput.publicPath || '/',
|
|
23
|
+
filename: 'server-bundle.js',
|
|
24
|
+
libraryTarget: 'commonjs2',
|
|
25
|
+
chunkFilename: 'js/[name].[chunkhash].js'
|
|
26
|
+
},
|
|
27
|
+
module: {
|
|
28
|
+
rules: [
|
|
29
|
+
{
|
|
30
|
+
oneOf: [
|
|
31
|
+
{
|
|
32
|
+
test: /\.(scss|css|sass)$/,
|
|
33
|
+
use: [
|
|
34
|
+
{
|
|
35
|
+
loader: 'ignore-loader'
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
// 服务端打包的时候忽略外部的npm包
|
|
44
|
+
externals: nodeExternals({
|
|
45
|
+
// 当然外部的css还是可以打进来的
|
|
46
|
+
whitelist: /\.(css|less|scss)$/
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
};
|