akfun 3.3.6 → 3.3.8

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.3.6",
3
+ "version": "3.3.8",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
package/src/build2esm.js CHANGED
@@ -1,10 +1,11 @@
1
1
  const ora = require('ora');
2
2
  const rollup = require('rollup');
3
+ const { terser } = require('rollup-plugin-terser'); // 压缩
3
4
  const projectConfig = require('./config/index'); // 引入当前项目配置文件
4
5
  const defaultConfig = require('./config/default.config');
5
6
  const rollupConfig = require('./config/rollup.config'); // rollup的配置文件
6
7
  const { isArray, isObject } = require('./utils/typeof');
7
- const {curConsoleTag } = require("./utils/akfunParams");
8
+ const { curConsoleTag } = require('./utils/akfunParams');
8
9
  const deepMergeConfig = require('./utils/deepMergeConfig');
9
10
 
10
11
  async function build2esmFunc(options, curConfig) {
@@ -37,11 +38,22 @@ module.exports = function (fileName, akfunConfig, _consoleTag) {
37
38
  const spinner = ora(`${consoleTag}开启esm模块构建能力...`).start();
38
39
  const curRollupConfig = rollupConfig(fileName, config); // 默认配置
39
40
  const build2esm = config.build2esm; // 用户的项目配置
41
+ const compress = build2esm.compress ?? true; // 是否压缩代码
40
42
  if (build2esm && build2esm.input) {
41
43
  curRollupConfig.input = build2esm.input;
42
44
  }
43
45
  if (build2esm && build2esm.output) {
44
46
  curRollupConfig.output = build2esm.output;
47
+
48
+ if (isArray(build2esm.output)) {
49
+ build2esm.output.map((outputItem) => {
50
+ if (!outputItem.plugins && compress) {
51
+ outputItem.plugins = [terser()];
52
+ }
53
+ });
54
+ } else if (isObject(build2esm.output) && !build2esm.output.plugins && compress) {
55
+ build2esm.output.plugins = [terser()];
56
+ }
45
57
  }
46
58
  build2esmFunc(curRollupConfig, config).then(() => {
47
59
  spinner.succeed(`${consoleTag}esm模块构建完成。`);
@@ -51,8 +51,8 @@ module.exports = (akfunConfig) => {
51
51
  devtool: curEnvConfig.productionSourceMap ? curEnvConfig.devtool || 'eval-source-map' : 'eval', // 开发环境
52
52
  optimization: {
53
53
  chunkIds: 'named', // named 对调试更友好的可读的 id。
54
- emitOnErrors: true,
55
- minimize: false
54
+ emitOnErrors: true
55
+ // minimize: false
56
56
  },
57
57
  plugins: [
58
58
  // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
@@ -53,7 +53,7 @@ module.exports = (akfunConfig) => {
53
53
  */
54
54
  chunkIds: 'named',
55
55
  emitOnErrors: true,
56
- minimize: true,
56
+ // minimize: true,
57
57
  minimizer: [
58
58
  // For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
59
59
  `...`,
@@ -80,7 +80,7 @@ module.exports = (akfunConfig) => {
80
80
  }
81
81
  }
82
82
  },
83
- minimize: true,
83
+ // minimize: true,
84
84
  minimizer: [
85
85
  // For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
86
86
  `...`,