akfun 3.2.0 → 3.2.1
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 +1 -1
- package/src/config/rollup.config.js +13 -6
package/package.json
CHANGED
|
@@ -19,30 +19,37 @@ 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
|
-
|
|
48
|
+
/**
|
|
49
|
+
* external:(在akfun.config.js中配置)
|
|
50
|
+
* 需要一个 id 并返回 true(外部引用)或 false(不是外部的引用), 或者 Array 应该保留在bundle的外部引用的模块ID。
|
|
51
|
+
*/
|
|
52
|
+
external: build2esm.external || [],
|
|
46
53
|
plugins: [
|
|
47
54
|
alias({
|
|
48
55
|
resolve: curConfig.webpack.resolve.extensions,
|