akfun 3.2.2 → 3.2.6
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/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -3,7 +3,7 @@ const rm = require('rimraf');
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const webpack = require('webpack');
|
|
6
|
-
const {curConsoleTag} = require(
|
|
6
|
+
const { curConsoleTag } = require('./utils/akfunParams');
|
|
7
7
|
const checkVersion = require('./check-versions');
|
|
8
8
|
const projectConfig = require('./config/index'); // 引入当前项目配置文件
|
|
9
9
|
const defaultConfig = require('./config/default.config');
|
|
@@ -17,6 +17,7 @@ module.exports = function (BuildType, akfunConfig, _consoleTag) {
|
|
|
17
17
|
// 参数中的config配置优先级最高
|
|
18
18
|
config = deepMergeConfig(defaultConfig, akfunConfig);
|
|
19
19
|
}
|
|
20
|
+
let curEnvConfig = config.build;
|
|
20
21
|
// 检查当前npm版本号是否匹配
|
|
21
22
|
checkVersion();
|
|
22
23
|
const spinner = ora(`${consoleTag}开始构建...`).start();
|
|
@@ -26,6 +27,7 @@ module.exports = function (BuildType, akfunConfig, _consoleTag) {
|
|
|
26
27
|
if (BuildType && BuildType === 'lib') {
|
|
27
28
|
spinner.start(`${consoleTag}开始构建lib库...`);
|
|
28
29
|
webpackConfig = require('./webpack/webpack.library.conf')(config);
|
|
30
|
+
curEnvConfig = config.build2lib;
|
|
29
31
|
} else {
|
|
30
32
|
spinner.start(`${consoleTag}开始构建生产环境的代码...`);
|
|
31
33
|
webpackConfig = require('./webpack/webpack.prod.conf')(config);
|
|
@@ -36,10 +38,10 @@ module.exports = function (BuildType, akfunConfig, _consoleTag) {
|
|
|
36
38
|
* 使用 config.dev.NODE_ENV 作为当前的环境
|
|
37
39
|
*/
|
|
38
40
|
if (!process.NODE_ENV) {
|
|
39
|
-
process.NODE_ENV =
|
|
41
|
+
process.NODE_ENV = curEnvConfig.NODE_ENV; // 将运行环境设置为生产环境
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
rm(path.join(
|
|
44
|
+
rm(path.join(curEnvConfig.assetsRoot, curEnvConfig.assetsSubDirectory), (err) => {
|
|
43
45
|
if (err) throw err;
|
|
44
46
|
webpack(webpackConfig, (err, stats) => {
|
|
45
47
|
spinner.stop();
|
|
@@ -311,5 +311,11 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
|
|
|
311
311
|
webpackConfig.plugins.push(...curWebpackConfig.plugins);
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
// 判断是否有自定义loader
|
|
315
|
+
if (curWebpackConfig.moduleRules && Array.isArray(curWebpackConfig.moduleRules)) {
|
|
316
|
+
// 添加自定义自定义loader
|
|
317
|
+
webpackConfig.module.rules.push(...curWebpackConfig.moduleRules);
|
|
318
|
+
}
|
|
319
|
+
|
|
314
320
|
return webpackConfig;
|
|
315
321
|
};
|
|
@@ -71,5 +71,11 @@ module.exports = (akfunConfig) => {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// 判断当前环境是否有自定义plugins
|
|
75
|
+
if (curEnvConfig.plugins && Array.isArray(curEnvConfig.plugins)) {
|
|
76
|
+
// 添加自定义webpack插件
|
|
77
|
+
webpackDevConfig.plugins.push(...curEnvConfig.plugins);
|
|
78
|
+
}
|
|
79
|
+
|
|
74
80
|
return webpackDevConfig;
|
|
75
81
|
};
|
|
@@ -74,6 +74,12 @@ module.exports = (akfunConfig) => {
|
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
// 判断当前环境是否有自定义plugins
|
|
78
|
+
if (curEnvConfig.plugins && Array.isArray(curEnvConfig.plugins)) {
|
|
79
|
+
// 添加自定义webpack插件
|
|
80
|
+
webpackLibConfig.plugins.push(...curEnvConfig.plugins);
|
|
81
|
+
}
|
|
82
|
+
|
|
77
83
|
if (curEnvConfig.bundleAnalyzerReport) {
|
|
78
84
|
webpackLibConfig.plugins.push(new BundleAnalyzerPlugin());
|
|
79
85
|
}
|
|
@@ -132,6 +132,12 @@ module.exports = (akfunConfig) => {
|
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
// 判断当前环境是否有自定义plugins
|
|
136
|
+
if (curEnvConfig.plugins && Array.isArray(curEnvConfig.plugins)) {
|
|
137
|
+
// 添加自定义webpack插件
|
|
138
|
+
webpackProdConfig.plugins.push(...curEnvConfig.plugins);
|
|
139
|
+
}
|
|
140
|
+
|
|
135
141
|
if (curEnvConfig.bundleAnalyzerReport) {
|
|
136
142
|
webpackProdConfig.plugins.push(new BundleAnalyzerPlugin());
|
|
137
143
|
}
|