akfun 3.2.0 → 3.2.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "akfun",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
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",
|
|
@@ -19,36 +19,45 @@ const nested = require('postcss-nested');
|
|
|
19
19
|
const postcssPresetEnv = require('postcss-preset-env');
|
|
20
20
|
// css代码压缩
|
|
21
21
|
const cssnano = require('cssnano');
|
|
22
|
+
const { externals } = require('rollup-plugin-node-externals');
|
|
22
23
|
const { resolveToCurrentRoot, resolveToCurrentDist } = require('../utils/pathUtils'); // 统一路径解析
|
|
23
24
|
const babelConfig = require('./babel.config'); // Babel的配置文件
|
|
24
|
-
const
|
|
25
|
+
const projectConfig = require('./index'); // 引入当前项目配置文件
|
|
25
26
|
const { buildBanner } = require('../utils/akfunParams');
|
|
26
27
|
|
|
27
28
|
module.exports = function (fileName, akfunConfig) {
|
|
28
29
|
const curConfig = akfunConfig || curProjectConfig;
|
|
30
|
+
const build2esm = curConfig.build2esm || {};
|
|
29
31
|
// 获取用户配置的构建入口文件
|
|
30
32
|
let rollupInput = resolveToCurrentRoot('src/main.js');
|
|
31
|
-
if (
|
|
32
|
-
rollupInput =
|
|
33
|
+
if (build2esm.input) {
|
|
34
|
+
rollupInput = build2esm.input;
|
|
33
35
|
}
|
|
34
36
|
let curFileName = fileName || 'index'; // 默认以"index.esm.js"输出
|
|
35
37
|
// 获取用户配置的构建输出文件名
|
|
36
|
-
if (
|
|
37
|
-
curFileName =
|
|
38
|
+
if (build2esm.fileName) {
|
|
39
|
+
curFileName = build2esm.fileName;
|
|
38
40
|
}
|
|
39
41
|
// 增加babel配置
|
|
40
42
|
babelConfig.babelHelpers = 'runtime';
|
|
41
43
|
|
|
42
44
|
return {
|
|
43
45
|
banner: buildBanner,
|
|
46
|
+
// format: build2esm.format || 'esm', // 生成包的格式
|
|
44
47
|
input: rollupInput,
|
|
45
|
-
// external:将模块视为外部模块,不会打包在库中(在akfun.config.js中配置)
|
|
46
48
|
plugins: [
|
|
47
49
|
alias({
|
|
48
50
|
resolve: curConfig.webpack.resolve.extensions,
|
|
49
51
|
extensions: curConfig.webpack.resolve.extensions,
|
|
50
52
|
entries: curConfig.webpack.resolve.alias
|
|
51
53
|
}),
|
|
54
|
+
/**
|
|
55
|
+
* excludeList(在akfun.config.js中配置)
|
|
56
|
+
* 设置打包中应该排除的依赖
|
|
57
|
+
*/
|
|
58
|
+
externals({
|
|
59
|
+
include: build2esm.excludeList || []
|
|
60
|
+
}),
|
|
52
61
|
nodeResolve({
|
|
53
62
|
extensions: curConfig.webpack.resolve.extensions
|
|
54
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
|
}
|