@autobest-ui/scripts 0.0.5 → 0.1.3
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 -193
- package/package.json +2 -3
- 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
package/common/webpack.common.js
CHANGED
|
@@ -1,193 +1,218 @@
|
|
|
1
|
-
const webpack = require('webpack');
|
|
2
|
-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
3
|
-
const HappyPack = require('happypack');
|
|
4
|
-
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
5
|
-
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
|
|
6
|
-
const getCSSModuleLocalIdent = require('./getCSSModuleLocalIdent');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
new
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
'@
|
|
159
|
-
'@babel/
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
};
|
|
1
|
+
const webpack = require('webpack');
|
|
2
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
3
|
+
const HappyPack = require('happypack');
|
|
4
|
+
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
5
|
+
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
|
|
6
|
+
const getCSSModuleLocalIdent = require('./getCSSModuleLocalIdent');
|
|
7
|
+
const { getProjectPath, isExistsSyncFile } = require('./utils');
|
|
8
|
+
|
|
9
|
+
const appWebpackConfigPath = getProjectPath('/config/app.webpack.js');
|
|
10
|
+
|
|
11
|
+
const happyThreadPool = HappyPack.ThreadPool({ size: 5 });
|
|
12
|
+
const sassRegex = /\.(scss|sass)$/;
|
|
13
|
+
const sassModuleRegex = /\.module\.(scss|sass)$/;
|
|
14
|
+
|
|
15
|
+
function getStyleLoaders({ isProd, isServer, isHotServer, isSass, moduleOption = {} }) {
|
|
16
|
+
const result = [
|
|
17
|
+
{
|
|
18
|
+
loader: 'css-loader',
|
|
19
|
+
options: {
|
|
20
|
+
importLoaders: 1,
|
|
21
|
+
...moduleOption
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
loader: 'postcss-loader',
|
|
26
|
+
options: {
|
|
27
|
+
ident: 'postcss',
|
|
28
|
+
plugins: () => [
|
|
29
|
+
require('postcss-flexbugs-fixes'),
|
|
30
|
+
require('postcss-preset-env')({
|
|
31
|
+
autoprefixer: {
|
|
32
|
+
flexbox: 'no-2009',
|
|
33
|
+
remove: false,
|
|
34
|
+
grid: true
|
|
35
|
+
},
|
|
36
|
+
stage: 3
|
|
37
|
+
})
|
|
38
|
+
],
|
|
39
|
+
sourceMap: false
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
if (isSass) {
|
|
45
|
+
result.push({
|
|
46
|
+
loader: 'sass-loader'
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if ((isProd || isHotServer) && !isServer) {
|
|
51
|
+
result.unshift({
|
|
52
|
+
loader: MiniCssExtractPlugin.loader,
|
|
53
|
+
options: {
|
|
54
|
+
hmr: false
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!isProd && !isHotServer) {
|
|
60
|
+
result.unshift({
|
|
61
|
+
loader: 'style-loader'
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer, isSetCommonAlias }) => {
|
|
69
|
+
const result = {
|
|
70
|
+
// 原始源代码(仅限行)定位到原始代码问题,比source-map 快,但是没有列映射(column mapping)的 source-map
|
|
71
|
+
devtool: isProd ? 'source-map' : 'cheap-module-source-map',
|
|
72
|
+
// 会将 process.env.NODE_ENV 的值设为 development, 告知 webpack 使用相应模式的内置优化
|
|
73
|
+
mode: isProd ? 'production' : 'development',
|
|
74
|
+
// 打包的出口
|
|
75
|
+
output: {
|
|
76
|
+
publicPath: '/'
|
|
77
|
+
},
|
|
78
|
+
// 配置各种loader
|
|
79
|
+
module: {
|
|
80
|
+
// 警告替换为Error
|
|
81
|
+
strictExportPresence: true,
|
|
82
|
+
rules: [
|
|
83
|
+
{
|
|
84
|
+
oneOf: [
|
|
85
|
+
{
|
|
86
|
+
test: /\.(js|ts|tsx)$/,
|
|
87
|
+
exclude: /node_modules/,
|
|
88
|
+
use: 'happypack/loader?id=jsbabel'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
test: sassRegex,
|
|
92
|
+
exclude: sassModuleRegex,
|
|
93
|
+
use: getStyleLoaders({
|
|
94
|
+
isProd,
|
|
95
|
+
isServer,
|
|
96
|
+
isHotServer,
|
|
97
|
+
isSass: true
|
|
98
|
+
})
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
test: sassModuleRegex,
|
|
102
|
+
use: getStyleLoaders({
|
|
103
|
+
isProd,
|
|
104
|
+
isServer,
|
|
105
|
+
isHotServer,
|
|
106
|
+
isSass: true,
|
|
107
|
+
moduleOption: {
|
|
108
|
+
getLocalIdent: getCSSModuleLocalIdent,
|
|
109
|
+
importLoaders: 2,
|
|
110
|
+
modules: true
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
test: /\.(css)$/,
|
|
116
|
+
use: getStyleLoaders({
|
|
117
|
+
isProd,
|
|
118
|
+
isServer,
|
|
119
|
+
isHotServer
|
|
120
|
+
})
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
test: [/\.jpe?g$/, /\.png$/, /\.bmp$/, /\.gif$/],
|
|
124
|
+
loader: 'url-loader',
|
|
125
|
+
options: {
|
|
126
|
+
limit: 2048,
|
|
127
|
+
name: `static/[name].[contenthash:8].[ext]?v=${extendEnv.version}`
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
resolve: {
|
|
135
|
+
// 设置路径别名
|
|
136
|
+
alias: appConfig.alias,
|
|
137
|
+
// 文件后缀自动补全
|
|
138
|
+
extensions: ['.tsx', '.ts', '.js', 'scss', 'css']
|
|
139
|
+
},
|
|
140
|
+
plugins: [
|
|
141
|
+
new webpack.DefinePlugin(extendEnv.stringified),
|
|
142
|
+
new ESLintPlugin({
|
|
143
|
+
failOnError: false,
|
|
144
|
+
extensions: ['ts', 'tsx', 'js']
|
|
145
|
+
}),
|
|
146
|
+
new HappyPack({
|
|
147
|
+
id: 'jsbabel',
|
|
148
|
+
verbose: false,
|
|
149
|
+
threadPool: happyThreadPool,
|
|
150
|
+
loaders: [
|
|
151
|
+
{
|
|
152
|
+
loader: 'babel-loader',
|
|
153
|
+
options: {
|
|
154
|
+
cacheDirectory: true,
|
|
155
|
+
presets: [
|
|
156
|
+
'react-app',
|
|
157
|
+
'@babel/preset-env',
|
|
158
|
+
'@babel/preset-react',
|
|
159
|
+
'@babel/typescript'
|
|
160
|
+
],
|
|
161
|
+
plugins: [
|
|
162
|
+
'@loadable/babel-plugin',
|
|
163
|
+
'@babel/plugin-transform-object-assign',
|
|
164
|
+
'@babel/plugin-transform-shorthand-properties',
|
|
165
|
+
'@babel/plugin-transform-runtime',
|
|
166
|
+
[
|
|
167
|
+
'@babel/plugin-proposal-decorators',
|
|
168
|
+
{
|
|
169
|
+
legacy: true
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
[
|
|
173
|
+
'@babel/plugin-proposal-class-properties',
|
|
174
|
+
{
|
|
175
|
+
loose: false
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
}),
|
|
183
|
+
new ProgressBarPlugin({
|
|
184
|
+
// eslint-disable-next-line no-useless-concat
|
|
185
|
+
format: 'build [:bar] ' + ':percent' + ' (:elapsed seconds)',
|
|
186
|
+
clear: false
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
};
|
|
190
|
+
if (isProd && !isServer) {
|
|
191
|
+
result.optimization = {
|
|
192
|
+
minimize: true
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (isExistsSyncFile(appWebpackConfigPath)) {
|
|
197
|
+
const extendConfig = require(appWebpackConfigPath);
|
|
198
|
+
if (typeof extendConfig !== 'function') {
|
|
199
|
+
throw Error(
|
|
200
|
+
`Extend webpack config file only functions are supported and return extend result! \n current type is ${typeof extendConfig} \n filename is ${appWebpackConfigPath}`
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
const extendResult = extendConfig(result, appConfig, extendEnv, {
|
|
204
|
+
isProd,
|
|
205
|
+
isServer,
|
|
206
|
+
isHotServer,
|
|
207
|
+
isSetCommonAlias
|
|
208
|
+
});
|
|
209
|
+
if (!extendResult) {
|
|
210
|
+
throw Error(
|
|
211
|
+
`Return extend result! \n current extendResult is ${extendResult} \n filename is ${appWebpackConfigPath}`
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
return extendResult;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return result;
|
|
218
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobest-ui/scripts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "utils for project tools",
|
|
6
6
|
"bin": {
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://autobest.visualstudio.com/AutoBestChina/_git/AutobestFrontendCommon#readme",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@autobest-ui/replace-loader": "^0.0.8",
|
|
48
47
|
"@babel/core": "7.13.0",
|
|
49
48
|
"@babel/plugin-proposal-class-properties": "7.12.13",
|
|
50
49
|
"@babel/plugin-proposal-decorators": "7.14.2",
|
|
@@ -94,5 +93,5 @@
|
|
|
94
93
|
"webpack-merge": "^4.2.1",
|
|
95
94
|
"webpack-node-externals": "1.7.2"
|
|
96
95
|
},
|
|
97
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "b484799b609493162ff338ebdb701a77f2d979a4"
|
|
98
97
|
}
|
package/spaConfig/build.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
const webpack = require('webpack');
|
|
2
|
-
const chalk = require('chalk');
|
|
3
|
-
const appConfig = require('../common/appConfig');
|
|
4
|
-
const { runCallback } = require('../common/build');
|
|
5
|
-
const getClientEnvironment = require('../common/extendEnv');
|
|
6
|
-
const webpackFactory = require('./webpack.prod');
|
|
7
|
-
|
|
8
|
-
process.env.BABEL_ENV = 'production';
|
|
9
|
-
process.env.NODE_ENV = 'production';
|
|
10
|
-
|
|
11
|
-
process.on('unhandledRejection', err => {
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
13
|
-
throw err;
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const extendEnv = getClientEnvironment();
|
|
17
|
-
|
|
18
|
-
function build() {
|
|
19
|
-
const config = webpackFactory(appConfig, extendEnv);
|
|
20
|
-
// eslint-disable-next-line no-console
|
|
21
|
-
console.log(chalk.green('Creating an optimized production build...'));
|
|
22
|
-
const compiler = webpack(config);
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
compiler.run(runCallback(resolve, reject));
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
build()
|
|
29
|
-
.then(
|
|
30
|
-
({ warnings }) => {
|
|
31
|
-
if (warnings.length) {
|
|
32
|
-
// eslint-disable-next-line no-console
|
|
33
|
-
console.log(chalk.yellow('Compiled with warnings.\n'));
|
|
34
|
-
// eslint-disable-next-line no-console
|
|
35
|
-
console.log(warnings.join('\n\n'));
|
|
36
|
-
// eslint-disable-next-line no-console
|
|
37
|
-
console.log(
|
|
38
|
-
`\nSearch for the ${chalk.underline(
|
|
39
|
-
chalk.yellow('keywords')
|
|
40
|
-
)} to learn more about each warning.`
|
|
41
|
-
);
|
|
42
|
-
// eslint-disable-next-line no-console
|
|
43
|
-
console.log(
|
|
44
|
-
`To ignore, add ${chalk.cyan('// eslint-disable-next-line')} to the line before.\n`
|
|
45
|
-
);
|
|
46
|
-
} else {
|
|
47
|
-
// eslint-disable-next-line no-console
|
|
48
|
-
console.log(chalk.green('Compiled successfully.\n'));
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
err => {
|
|
52
|
-
// eslint-disable-next-line no-console
|
|
53
|
-
console.log(chalk.red('Failed to compile.\n'));
|
|
54
|
-
// eslint-disable-next-line no-console
|
|
55
|
-
console.log(err);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
.catch(err => {
|
|
60
|
-
// eslint-disable-next-line no-console
|
|
61
|
-
console.log(chalk.red('Failed to compile.\n'));
|
|
62
|
-
// eslint-disable-next-line no-console
|
|
63
|
-
console.log(err);
|
|
64
|
-
process.exit(1);
|
|
65
|
-
});
|
|
1
|
+
const webpack = require('webpack');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const appConfig = require('../common/appConfig');
|
|
4
|
+
const { runCallback } = require('../common/build');
|
|
5
|
+
const getClientEnvironment = require('../common/extendEnv');
|
|
6
|
+
const webpackFactory = require('./webpack.prod');
|
|
7
|
+
|
|
8
|
+
process.env.BABEL_ENV = 'production';
|
|
9
|
+
process.env.NODE_ENV = 'production';
|
|
10
|
+
|
|
11
|
+
process.on('unhandledRejection', err => {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
13
|
+
throw err;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const extendEnv = getClientEnvironment();
|
|
17
|
+
|
|
18
|
+
function build() {
|
|
19
|
+
const config = webpackFactory(appConfig, extendEnv);
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.log(chalk.green('Creating an optimized production build...'));
|
|
22
|
+
const compiler = webpack(config);
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
compiler.run(runCallback(resolve, reject));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
build()
|
|
29
|
+
.then(
|
|
30
|
+
({ warnings }) => {
|
|
31
|
+
if (warnings.length) {
|
|
32
|
+
// eslint-disable-next-line no-console
|
|
33
|
+
console.log(chalk.yellow('Compiled with warnings.\n'));
|
|
34
|
+
// eslint-disable-next-line no-console
|
|
35
|
+
console.log(warnings.join('\n\n'));
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
37
|
+
console.log(
|
|
38
|
+
`\nSearch for the ${chalk.underline(
|
|
39
|
+
chalk.yellow('keywords')
|
|
40
|
+
)} to learn more about each warning.`
|
|
41
|
+
);
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.log(
|
|
44
|
+
`To ignore, add ${chalk.cyan('// eslint-disable-next-line')} to the line before.\n`
|
|
45
|
+
);
|
|
46
|
+
} else {
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
console.log(chalk.green('Compiled successfully.\n'));
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
err => {
|
|
52
|
+
// eslint-disable-next-line no-console
|
|
53
|
+
console.log(chalk.red('Failed to compile.\n'));
|
|
54
|
+
// eslint-disable-next-line no-console
|
|
55
|
+
console.log(err);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
.catch(err => {
|
|
60
|
+
// eslint-disable-next-line no-console
|
|
61
|
+
console.log(chalk.red('Failed to compile.\n'));
|
|
62
|
+
// eslint-disable-next-line no-console
|
|
63
|
+
console.log(err);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
});
|
package/spaConfig/start.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const webpackFactory = require('./webpack.dev');
|
|
2
|
-
const openStartRun = require('../common/start');
|
|
3
|
-
|
|
4
|
-
openStartRun(webpackFactory);
|
|
1
|
+
const webpackFactory = require('./webpack.dev');
|
|
2
|
+
const openStartRun = require('../common/start');
|
|
3
|
+
|
|
4
|
+
openStartRun(webpackFactory);
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const merge = require('webpack-merge');
|
|
2
|
-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
3
|
-
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
4
|
-
const { getProjectPath } = require('../common/utils');
|
|
5
|
-
const webpackCommon = require('../common/webpack.common');
|
|
6
|
-
|
|
7
|
-
module.exports = (isProd, appConfig, extendEnv) => {
|
|
8
|
-
const result = {
|
|
9
|
-
plugins: [
|
|
10
|
-
new HtmlWebpackPlugin({
|
|
11
|
-
inject: true,
|
|
12
|
-
template: getProjectPath(appConfig.htmlPluginTemplate)
|
|
13
|
-
})
|
|
14
|
-
]
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
if (isProd) {
|
|
18
|
-
result.plugins.push(
|
|
19
|
-
new MiniCssExtractPlugin({
|
|
20
|
-
filename: `css/[name].css?v=${extendEnv.version}`,
|
|
21
|
-
allChunks: true,
|
|
22
|
-
ignoreOrder: true
|
|
23
|
-
})
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return merge(webpackCommon(appConfig, extendEnv, { isProd, isServer: false }), result);
|
|
28
|
-
};
|
|
1
|
+
const merge = require('webpack-merge');
|
|
2
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
3
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
4
|
+
const { getProjectPath } = require('../common/utils');
|
|
5
|
+
const webpackCommon = require('../common/webpack.common');
|
|
6
|
+
|
|
7
|
+
module.exports = (isProd, appConfig, extendEnv) => {
|
|
8
|
+
const result = {
|
|
9
|
+
plugins: [
|
|
10
|
+
new HtmlWebpackPlugin({
|
|
11
|
+
inject: true,
|
|
12
|
+
template: getProjectPath(appConfig.htmlPluginTemplate)
|
|
13
|
+
})
|
|
14
|
+
]
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
if (isProd) {
|
|
18
|
+
result.plugins.push(
|
|
19
|
+
new MiniCssExtractPlugin({
|
|
20
|
+
filename: `css/[name].css?v=${extendEnv.version}`,
|
|
21
|
+
allChunks: true,
|
|
22
|
+
ignoreOrder: true
|
|
23
|
+
})
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return merge(webpackCommon(appConfig, extendEnv, { isProd, isServer: false }), result);
|
|
28
|
+
};
|