akfun 3.2.1 → 3.2.5
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "akfun",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.5",
|
|
4
4
|
"description": "前端脚手架:支持Vue技术栈和react技术栈",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"前端工程",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"@rollup/plugin-json": "^4.1.0",
|
|
75
75
|
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
76
76
|
"@rollup/plugin-typescript": "^8.3.1",
|
|
77
|
+
"rollup-plugin-node-externals": "^4.0.0",
|
|
77
78
|
"@typescript-eslint/eslint-plugin": "^5.10.2",
|
|
78
79
|
"@typescript-eslint/parser": "^5.10.2",
|
|
79
80
|
"@vue/compiler-sfc": "^3.2.29",
|
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();
|
|
@@ -19,7 +19,7 @@ const nested = require('postcss-nested');
|
|
|
19
19
|
const postcssPresetEnv = require('postcss-preset-env');
|
|
20
20
|
// css代码压缩
|
|
21
21
|
const cssnano = require('cssnano');
|
|
22
|
-
|
|
22
|
+
const { externals } = require('rollup-plugin-node-externals');
|
|
23
23
|
const { resolveToCurrentRoot, resolveToCurrentDist } = require('../utils/pathUtils'); // 统一路径解析
|
|
24
24
|
const babelConfig = require('./babel.config'); // Babel的配置文件
|
|
25
25
|
const projectConfig = require('./index'); // 引入当前项目配置文件
|
|
@@ -45,17 +45,19 @@ module.exports = function (fileName, akfunConfig) {
|
|
|
45
45
|
banner: buildBanner,
|
|
46
46
|
// format: build2esm.format || 'esm', // 生成包的格式
|
|
47
47
|
input: rollupInput,
|
|
48
|
-
/**
|
|
49
|
-
* external:(在akfun.config.js中配置)
|
|
50
|
-
* 需要一个 id 并返回 true(外部引用)或 false(不是外部的引用), 或者 Array 应该保留在bundle的外部引用的模块ID。
|
|
51
|
-
*/
|
|
52
|
-
external: build2esm.external || [],
|
|
53
48
|
plugins: [
|
|
54
49
|
alias({
|
|
55
50
|
resolve: curConfig.webpack.resolve.extensions,
|
|
56
51
|
extensions: curConfig.webpack.resolve.extensions,
|
|
57
52
|
entries: curConfig.webpack.resolve.alias
|
|
58
53
|
}),
|
|
54
|
+
/**
|
|
55
|
+
* excludeList(在akfun.config.js中配置)
|
|
56
|
+
* 设置打包中应该排除的依赖
|
|
57
|
+
*/
|
|
58
|
+
externals({
|
|
59
|
+
include: build2esm.excludeList || []
|
|
60
|
+
}),
|
|
59
61
|
nodeResolve({
|
|
60
62
|
extensions: curConfig.webpack.resolve.extensions
|
|
61
63
|
}),
|
|
@@ -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
|
}
|