akfun 1.5.15 → 1.5.19

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/README.md CHANGED
@@ -270,7 +270,19 @@ module.exports = {
270
270
  }
271
271
  ```
272
272
 
273
- 9. 项目源码环境变量批量替换
273
+ 9. 配置项目源码目录(工程有效目录范围): projectDir
274
+ > 构建项目中,设置生效的目录(可同时设置多个目录),用于提高前端工程执行效率。可以不配置,默认为['./src']
275
+ ```bash
276
+ module.exports = {
277
+ ...
278
+ webpack: {
279
+ projectDir: ['./src'],
280
+ }
281
+ ...
282
+ }
283
+ ```
284
+
285
+ 10. 项目源码环境变量批量替换
274
286
  > [关于params-replace-loader的使用方法](https://www.npmjs.com/package/params-replace-loader)
275
287
  ```bash
276
288
  module.exports = {
@@ -289,7 +301,7 @@ module.exports = {
289
301
  }
290
302
  ```
291
303
 
292
- 10. 接口代理配置:目前只有dev本地开发调试模式下会启动
304
+ 11. 接口代理配置:目前只有dev本地开发调试模式下会启动
293
305
  > [关于proxyTable的配置方法](https://www.webpackjs.com/configuration/dev-server/#devserver-proxy)
294
306
  ```bash
295
307
  module.exports = {
@@ -302,7 +314,7 @@ module.exports = {
302
314
  }
303
315
  ```
304
316
 
305
- 11. 用于开启本地调试模式的相关配置信息
317
+ 12. 用于开启本地调试模式的相关配置信息
306
318
  ```bash
307
319
  module.exports = {
308
320
  ...
@@ -326,7 +338,7 @@ module.exports = {
326
338
  }
327
339
  ```
328
340
 
329
- 12. 用于构建生产环境代码的相关配置信息
341
+ 13. 用于构建生产环境代码的相关配置信息
330
342
  ```bash
331
343
  module.exports = {
332
344
  ...
@@ -344,7 +356,7 @@ module.exports = {
344
356
  }
345
357
  ```
346
358
 
347
- 13. 用于构建第三方功能包的配置(以umd格式输出)
359
+ 14. 用于构建第三方功能包的配置(以umd格式输出)
348
360
  ```bash
349
361
  module.exports = {
350
362
  ...
@@ -363,7 +375,7 @@ module.exports = {
363
375
  }
364
376
  ```
365
377
 
366
- 14. 用于构建esm格式的第三方功能包配置
378
+ 15. 用于构建esm格式的第三方功能包配置
367
379
  ```bash
368
380
  module.exports = {
369
381
  ...
package/module/index.js CHANGED
@@ -137,7 +137,7 @@ let argv = yargs
137
137
  .alias('h', 'help');
138
138
  },
139
139
  (argv) => {
140
- mainAction.build();
140
+ mainAction.build('prod');
141
141
  },
142
142
  )
143
143
  .command(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akfun",
3
- "version": "1.5.15",
3
+ "version": "1.5.19",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
@@ -73,7 +73,6 @@
73
73
  "@rollup/plugin-node-resolve": "^9.0.0",
74
74
  "@typescript-eslint/eslint-plugin": "^3.9.0",
75
75
  "@typescript-eslint/parser": "^3.9.0",
76
- "eslint-config-prettier": "^7.2.0",
77
76
  "@vue/compiler-sfc": "^3.0.0-rc.10",
78
77
  "@vue/eslint-config-typescript": "^5.0.2",
79
78
  "autoprefixer": "^9.8.0",
@@ -92,6 +91,7 @@
92
91
  "es6-promise-polyfill": "^1.2.0",
93
92
  "eslint": "^7.2.0",
94
93
  "eslint-config-airbnb-base": "^14.1.0",
94
+ "eslint-config-prettier": "^7.2.0",
95
95
  "eslint-friendly-formatter": "^4.0.1",
96
96
  "eslint-import-resolver-webpack": "^0.12.1",
97
97
  "eslint-loader": "^4.0.2",
@@ -112,6 +112,7 @@
112
112
  "http-proxy-middleware": "^1.0.4",
113
113
  "inquirer": "^7.3.3",
114
114
  "mini-css-extract-plugin": "^0.9.0",
115
+ "monaco-editor-webpack-plugin": "6.0.0",
115
116
  "node-sass": "^4.14.1",
116
117
  "opn": "^6.0.0",
117
118
  "optimize-css-assets-webpack-plugin": "^5.0.3",
@@ -152,8 +153,8 @@
152
153
  "webpack-dev-middleware": "^3.7.2",
153
154
  "webpack-hot-middleware": "^2.25.0",
154
155
  "webpack-merge": "^4.2.2",
155
- "yargs": "^12.0.2",
156
- "webpack-node-externals": "^3.0.0"
156
+ "webpack-node-externals": "^3.0.0",
157
+ "yargs": "^12.0.2"
157
158
  },
158
159
  "devDependencies": {
159
160
  "@commitlint/cli": "^8.3.5",
package/src/build.js CHANGED
@@ -4,10 +4,15 @@ const path = require('path');
4
4
  const chalk = require('chalk');
5
5
  const webpack = require('webpack');
6
6
  const checkVersion = require('./check-versions');
7
- const config = require('./config/index'); // 引入当前项目配置文件
7
+ const projectConfig = require('./config/index'); // 引入当前项目配置文件
8
+ const deepMergeConfig = require('./utils/deepMergeConfig');
8
9
 
9
10
  // 构建脚本:一般用于构建生产环境的代码
10
- module.exports = function (BuildType) {
11
+ module.exports = function (BuildType, akfunConfig) {
12
+ let config = projectConfig; // 默认使用执行命令目录下的配置数据
13
+ if (akfunConfig) {
14
+ config = deepMergeConfig(defaultConfig, akfunConfig);
15
+ }
11
16
  // 检查当前npm版本号是否匹配
12
17
  checkVersion();
13
18
  const spinner = ora('[akfun]开启AKFun构建能力...').start();
@@ -16,10 +21,10 @@ module.exports = function (BuildType) {
16
21
  // 根据BuildType判断是否引用专用于第三方功能包的webpack配置
17
22
  if (BuildType && BuildType === 'lib') {
18
23
  spinner.start('[akfun]开始构建第三方功能包...');
19
- webpackConfig = require('./webpack/webpack.library.conf')();
24
+ webpackConfig = require('./webpack/webpack.library.conf')(config);
20
25
  } else {
21
26
  spinner.start('[akfun]开始构建生产环境的代码...');
22
- webpackConfig = require('./webpack/webpack.prod.conf')();
27
+ webpackConfig = require('./webpack/webpack.prod.conf')(config);
23
28
  }
24
29
 
25
30
  /**
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+ // 统一路径解析:
3
+ const { resolve } = require('../utils/pathUtils');
4
+
5
+ /**
6
+ * akfun脚手架赋予当前项目的默认配置
7
+ */
8
+ const defaultAKFunConfig = {
9
+ settings: {
10
+ enableESLint: false, // 是否开启ESLint,默认开启ESLint检测代码格式
11
+ enableESLintFix: false, // 是否ESLint自动修正代码格式
12
+ enableStyleLint: false, // 是否开启StyleLint,默认开启ESLint检测代码格式
13
+ enableStyleLintFix: false // 是否需要StyleLint自动修正代码格式
14
+ },
15
+ webpack: {
16
+ resolve: {
17
+ // webpack的resolve配置
18
+ extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue', '.json'], // 用于配置webpack在尝试过程中用到的后缀列表
19
+ alias: {
20
+ '@': resolve('src'),
21
+ $components: resolve('src/components'),
22
+ $pages: resolve('src/pages'),
23
+ $plugins: resolve('src/plugins'),
24
+ $utils: resolve('src/utils')
25
+ }
26
+ },
27
+ createDeclaration: false, // 打包时是否创建ts声明文件
28
+ ignoreNodeModules: false, // 打包时是否忽略 node_modules
29
+ externals: [], // 从输出的 bundle 中排除依赖
30
+ sassResources: []
31
+ },
32
+ envParams: {
33
+ // 项目系统环境变量
34
+ common: {
35
+ // 通用参数
36
+ '#version#': '20200810.1'
37
+ },
38
+ local: {
39
+ // 本地开发环境
40
+ '#dataApiBase#': 'http://localhost:1024', // 数据接口根地址
41
+ '#assetsPublicPath#': 'http://localhost:1024', // 静态资源根地址
42
+ '#routeBasePath#': '/' // 路由根地址
43
+ },
44
+ online: {
45
+ // 线上正式环境配置参数
46
+ '#dataApiBase#': '/', // 数据接口根地址 "//xxx.cn/"格式
47
+ '#assetsPublicPath#': '', // 静态资源根地址 "//xxx.cn/_spa/projectName"格式
48
+ '#routeBasePath#': '/' // 路由根地址 "/_spa/projectName/"格式
49
+ }
50
+ },
51
+ dev: {
52
+ // 用于开启本地调试模式的相关配置信息
53
+ NODE_ENV: 'development',
54
+ port: 80,
55
+ autoOpenBrowser: true,
56
+ assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
57
+ assetsSubDirectory: '',
58
+ hostname: 'localhost',
59
+ proxyTable: {},
60
+ /** CSS Sourcemaps off by default because relative paths are "buggy"
61
+ * with this option, according to the CSS-Loader README
62
+ * (https://github.com/webpack/css-loader#sourcemaps)
63
+ * In our experience, they generally work as expected,
64
+ * just be aware of this issue when enabling this option.
65
+ */
66
+ cssSourceMap: false
67
+ },
68
+ build: {
69
+ // 用于构建生产环境代码的相关配置信息
70
+ NODE_ENV: 'production', // production 模式,会启动UglifyJsPlugin服务
71
+ assetsRoot: resolve('dist'), // 编译完成的文件存放路径
72
+ assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
73
+ assetsSubDirectory: '', // 资源引用二级路径
74
+ productionSourceMap: false,
75
+ // Gzip off by default as many popular public hosts such as
76
+ // Surge or Netlify already gzip all public assets for you.
77
+ // Before setting to `true`, make sure to:
78
+ // npm install --save-dev compression-webpack-plugin
79
+ productionGzip: false,
80
+ productionGzipExtensions: ['js', 'css', 'json'],
81
+ // Run the build command with an extra argument to
82
+ // View the bundle analyzer report after build finishes:
83
+ // `npm run build --report`
84
+ // Set to `true` or `false` to always turn it on or off
85
+ bundleAnalyzerReport: false
86
+ },
87
+ build2lib: {
88
+ // 用于构建第三方功能包的配置文件
89
+ NODE_ENV: 'production',
90
+ libraryName: '', // 构建第三方功能包时最后导出的引用变量名
91
+ assetsRoot: resolve('dist'), // 编译完成的文件存放路径
92
+ assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
93
+ assetsSubDirectory: '', // 资源引用二级路径
94
+ productionSourceMap: false,
95
+ productionGzip: false,
96
+ productionGzipExtensions: ['js', 'css', 'json'],
97
+ bundleAnalyzerReport: false
98
+ }
99
+ };
100
+
101
+ // 备注:数组类型则直接覆盖
102
+ module.exports = defaultAKFunConfig;
@@ -1,110 +1,15 @@
1
- 'use strict';
2
- const deepMerge = require('deepmerge');
3
1
  // 统一路径解析:
4
2
  const { resolve } = require('../utils/pathUtils');
3
+ const defaultAKFunConfig = require('./default.config');
5
4
  const getConfigObj = require('../utils/getConfigObj');
5
+ const deepMergeConfig = require('../utils/deepMergeConfig');
6
6
 
7
7
  /** akfun脚手架赋予当前项目的默认配置
8
8
  * 备注:项目根目录的akfun.config.js的配置内容优先级高于defultAKFunConfig
9
9
  */
10
- const defaultAKFunConfig = {
11
- settings: {
12
- enableESLint: false, // 是否开启ESLint,默认开启ESLint检测代码格式
13
- enableESLintFix: false, // 是否ESLint自动修正代码格式
14
- enableStyleLint: false, // 是否开启StyleLint,默认开启ESLint检测代码格式
15
- enableStyleLintFix: false // 是否需要StyleLint自动修正代码格式
16
- },
17
- webpack: {
18
- resolve: {
19
- // webpack的resolve配置
20
- extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue', '.json'], // 用于配置webpack在尝试过程中用到的后缀列表
21
- alias: {
22
- '@': resolve('src'),
23
- $components: resolve('src/components'),
24
- $pages: resolve('src/pages'),
25
- $plugins: resolve('src/plugins'),
26
- $utils: resolve('src/utils')
27
- }
28
- },
29
- createDeclaration: false, // 打包时是否创建ts声明文件
30
- ignoreNodeModules: false, // 打包时是否忽略 node_modules
31
- externals: [], // 从输出的 bundle 中排除依赖
32
- sassResources: []
33
- },
34
- envParams: {
35
- // 项目系统环境变量
36
- common: {
37
- // 通用参数
38
- '#version#': '20200810.1'
39
- },
40
- local: {
41
- // 本地开发环境
42
- '#dataApiBase#': 'http://localhost:1024', // 数据接口根地址
43
- '#assetsPublicPath#': 'http://localhost:1024', // 静态资源根地址
44
- '#routeBasePath#': '/' // 路由根地址
45
- },
46
- online: {
47
- // 线上正式环境配置参数
48
- '#dataApiBase#': '/', // 数据接口根地址 "//xxx.cn/"格式
49
- '#assetsPublicPath#': '', // 静态资源根地址 "//xxx.cn/_spa/projectName"格式
50
- '#routeBasePath#': '/' // 路由根地址 "/_spa/projectName/"格式
51
- }
52
- },
53
- dev: {
54
- // 用于开启本地调试模式的相关配置信息
55
- NODE_ENV: 'development',
56
- port: 80,
57
- autoOpenBrowser: true,
58
- assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
59
- assetsSubDirectory: '',
60
- hostname: 'localhost',
61
- proxyTable: {},
62
- /** CSS Sourcemaps off by default because relative paths are "buggy"
63
- * with this option, according to the CSS-Loader README
64
- * (https://github.com/webpack/css-loader#sourcemaps)
65
- * In our experience, they generally work as expected,
66
- * just be aware of this issue when enabling this option.
67
- */
68
- cssSourceMap: false
69
- },
70
- build: {
71
- // 用于构建生产环境代码的相关配置信息
72
- NODE_ENV: 'production', // production 模式,会启动UglifyJsPlugin服务
73
- assetsRoot: resolve('dist'), // 编译完成的文件存放路径
74
- assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
75
- assetsSubDirectory: '', // 资源引用二级路径
76
- productionSourceMap: false,
77
- // Gzip off by default as many popular public hosts such as
78
- // Surge or Netlify already gzip all public assets for you.
79
- // Before setting to `true`, make sure to:
80
- // npm install --save-dev compression-webpack-plugin
81
- productionGzip: false,
82
- productionGzipExtensions: ['js', 'css', 'json'],
83
- // Run the build command with an extra argument to
84
- // View the bundle analyzer report after build finishes:
85
- // `npm run build --report`
86
- // Set to `true` or `false` to always turn it on or off
87
- bundleAnalyzerReport: false
88
- },
89
- build2lib: {
90
- // 用于构建第三方功能包的配置文件
91
- NODE_ENV: 'production',
92
- libraryName: '', // 构建第三方功能包时最后导出的引用变量名
93
- assetsRoot: resolve('dist'), // 编译完成的文件存放路径
94
- assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
95
- assetsSubDirectory: '', // 资源引用二级路径
96
- productionSourceMap: false,
97
- productionGzip: false,
98
- productionGzipExtensions: ['js', 'css', 'json'],
99
- bundleAnalyzerReport: false
100
- }
101
- };
102
10
 
103
11
  // 从项目根目录获取当前项目的配置文件
104
12
  const curProjectConfig = getConfigObj(resolve('akfun.config.js'));
105
13
 
106
- // module.exports = Object.assign(defaultAKFunConfig, curProjectConfig);
107
-
108
- const overwriteMerge = (destinationArray, sourceArray, options) => sourceArray;
109
14
  // 备注:数组类型则直接覆盖
110
- module.exports = deepMerge(defaultAKFunConfig, curProjectConfig, { arrayMerge: overwriteMerge });
15
+ module.exports = deepMergeConfig(defaultAKFunConfig, curProjectConfig);
package/src/dev-server.js CHANGED
@@ -7,11 +7,17 @@ const checkVersion = require('./check-versions');
7
7
  const { createProxyMiddleware } = require('http-proxy-middleware');
8
8
  const { resolve } = require('./utils/pathUtils');
9
9
  // 引入当前项目配置文件
10
- const config = require('./config/index');
10
+ const projectConfig = require('./config/index');
11
+ const defaultConfig = require('./config/default.config');
11
12
  const getDevWebpackConfig = require('./webpack/webpack.dev.conf');
13
+ const deepMergeConfig = require('./utils/deepMergeConfig');
12
14
 
13
15
  // 构建脚本:一般用于构建开发环境的代码(包含热更新、接口代理等功能)
14
- module.exports = function () {
16
+ module.exports = function (akfunConfig) {
17
+ let config = projectConfig; // 默认使用执行命令目录下的配置数据
18
+ if (akfunConfig) {
19
+ config = deepMergeConfig(defaultConfig, akfunConfig);
20
+ }
15
21
  // 检查当前npm版本号是否匹配
16
22
  checkVersion();
17
23
  const spinner = ora('[akfun]开启调试模式...').start();
@@ -35,7 +41,7 @@ module.exports = function () {
35
41
  // 使用 express 启动一个服务
36
42
  const app = express();
37
43
  // 获取开发环境的webpack基本配置
38
- const webpackConfig = getDevWebpackConfig();
44
+ const webpackConfig = getDevWebpackConfig(config);
39
45
  const compiler = webpack(webpackConfig); // 启动 webpack 进行编译
40
46
 
41
47
  // 启动 webpack-dev-middleware,将编译后的文件暂存到内存中
@@ -0,0 +1,9 @@
1
+ const deepMerge = require('deepmerge');
2
+
3
+ const deepMergeConfig = function (defaultConfig, curConfig) {
4
+ const overwriteMerge = (destinationArray, sourceArray, options) => sourceArray;
5
+
6
+ return deepMerge(defaultConfig, curConfig, { arrayMerge: overwriteMerge });
7
+ };
8
+
9
+ module.exports = deepMergeConfig;
@@ -0,0 +1,16 @@
1
+ const { resolveToCurrentRoot } = require('./pathUtils');
2
+ const { isArray, isString } = require('../utils/typeof');
3
+
4
+ module.exports = (_projectDir) => {
5
+ const curProjectDir = [];
6
+ if (!_projectDir) {
7
+ curProjectDir.push(resolveToCurrentRoot('./src'));
8
+ } else if (isArray(_projectDir)) {
9
+ _projectDir.forEach((dir) => {
10
+ curProjectDir.push(resolveToCurrentRoot(dir));
11
+ });
12
+ } else if (isString(_projectDir)) {
13
+ curProjectDir.push(resolveToCurrentRoot(_projectDir));
14
+ }
15
+ return curProjectDir;
16
+ };
@@ -7,6 +7,7 @@ const utils = require('./loaderUtils');
7
7
  const vueLoaderConfig = require('./vue-loader.conf');
8
8
  const { resolve, resolveToCurrentRoot, catchCurPackageJson } = require('../utils/pathUtils');
9
9
  const getConfigObj = require('../utils/getConfigObj');
10
+ const getProjectDir = require('../utils/getProjectDir');
10
11
  const catchVuePages = require('../utils/catchVuePages'); // 用于获取当前项目中的vue单文件
11
12
  // 引入当前项目配置文件
12
13
  const config = require('../config/index');
@@ -34,6 +35,8 @@ const BannerPack = new webpack.BannerPlugin({
34
35
  */
35
36
  module.exports = (option) => {
36
37
  const curEnvConfig = option || {}; // 用于接收当前运行环境配置变量
38
+ // 获取当前项目目录
39
+ const curProjectDir = getProjectDir(config.webpack.projectDir);
37
40
  const webpackConfig = {
38
41
  entry: config.webpack.entry,
39
42
  /*
@@ -81,7 +84,7 @@ module.exports = (option) => {
81
84
  }
82
85
  }
83
86
  ],
84
- include: [resolve('src')],
87
+ include: curProjectDir, // [resolve('src')],
85
88
  exclude: /node_modules/
86
89
  },
87
90
  {
@@ -92,7 +95,7 @@ module.exports = (option) => {
92
95
  options: babelConfig
93
96
  }
94
97
  ],
95
- include: [resolve('src')],
98
+ include: curProjectDir, // [resolve('src')],
96
99
  exclude: /node_modules/
97
100
  },
98
101
  {
@@ -134,7 +137,7 @@ module.exports = (option) => {
134
137
  {
135
138
  test: /\.(js|ts|tsx|jsx|vue|css|html)$/,
136
139
  loader: 'params-replace-loader',
137
- include: [resolve('src')],
140
+ include: curProjectDir, // [resolve('src')],
138
141
  exclude: [/node_modules/, resolve('src/mock/data')], // 排除不需要进行校验的文件夹
139
142
  options: config.envParams
140
143
  }
@@ -153,7 +156,7 @@ module.exports = (option) => {
153
156
  test: /\.tsx?$/,
154
157
  loader: 'eslint-loader',
155
158
  enforce: 'pre',
156
- include: [resolve('src')],
159
+ include: curProjectDir, // [resolve('src')],
157
160
  exclude: /node_modules/,
158
161
  options: {
159
162
  cache: true,
@@ -167,7 +170,7 @@ module.exports = (option) => {
167
170
  test: /\.jsx?$/,
168
171
  loader: 'eslint-loader',
169
172
  enforce: 'pre',
170
- include: [resolve('src')],
173
+ include: curProjectDir, // [resolve('src')],
171
174
  exclude: /node_modules/,
172
175
  options: {
173
176
  cache: true, // the cache is written to the ./node_modules/.cache/eslint-loader director
@@ -181,7 +184,7 @@ module.exports = (option) => {
181
184
  test: /\.vue$/,
182
185
  loader: 'eslint-loader',
183
186
  enforce: 'pre',
184
- include: [resolve('src')],
187
+ include: curProjectDir, // [resolve('src')],
185
188
  exclude: /node_modules/,
186
189
  options: {
187
190
  cache: true,
@@ -6,13 +6,14 @@ const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
6
6
  const ProgressBarPlugin = require('progress-bar-webpack-plugin');
7
7
  const utils = require('./loaderUtils');
8
8
  // 引入当前项目配置文件
9
- const config = require('../config/index');
9
+ const projectConfig = require('../config/index');
10
10
  const getBaseWebpackConfig = require('./webpack.base.conf');
11
11
  const getJsEntries = require('../utils/jsEntries');
12
12
  const entrys2htmlWebpackPlugin = require('../utils/entrys2htmlWebpackPlugin');
13
13
  const { isArray } = require('../utils/typeof');
14
14
 
15
- module.exports = () => {
15
+ module.exports = (akfunConfig) => {
16
+ let config = akfunConfig || projectConfig; // 默认使用执行命令目录下的配置数据
16
17
  const curEnvConfig = config.dev || {}; // 当前执行环境配置
17
18
  // 获取webpack基本配置
18
19
  const baseWebpackConfig = getBaseWebpackConfig(curEnvConfig);
@@ -10,10 +10,11 @@ const nodeExternals = require('webpack-node-externals');
10
10
 
11
11
  const utils = require('./loaderUtils');
12
12
  // 引入当前项目配置文件
13
- const config = require('../config/index');
13
+ const projectConfig = require('../config/index');
14
14
  const getBaseWebpackConfig = require('./webpack.base.conf');
15
15
 
16
- module.exports = () => {
16
+ module.exports = (akfunConfig) => {
17
+ let config = akfunConfig || projectConfig; // 默认使用执行命令目录下的配置数据
17
18
  const curEnvConfig = config.build2lib || {}; // 当前执行环境配置
18
19
  // 获取webpack基本配置
19
20
  const baseWebpackConfig = getBaseWebpackConfig(curEnvConfig);
@@ -43,7 +44,9 @@ module.exports = () => {
43
44
  'process.env.NODE_ENV': JSON.stringify(curEnvConfig.NODE_ENV)
44
45
  }),
45
46
  new MiniCssExtractPlugin({
46
- filename: utils.assetsPath('index.css'),
47
+ // filename: utils.assetsPath('index.css'),
48
+ filename: "[name].css",
49
+ chunkFilename: "[id].css",
47
50
  ignoreOrder: false
48
51
  }),
49
52
  new OptimizeCSSPlugin({
@@ -11,6 +11,7 @@ const CompressionWebpackPlugin = require('compression-webpack-plugin');
11
11
  const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
12
12
  const ProgressBarPlugin = require('progress-bar-webpack-plugin');
13
13
  const nodeExternals = require('webpack-node-externals');
14
+ const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
14
15
 
15
16
  const utils = require('./loaderUtils');
16
17
  const { resolve } = require('../utils/pathUtils'); // 统一路径解析
@@ -18,10 +19,11 @@ const getJsEntries = require('../utils/jsEntries');
18
19
  const entrys2htmlWebpackPlugin = require('../utils/entrys2htmlWebpackPlugin');
19
20
  const { isArray } = require('../utils/typeof');
20
21
  // 引入当前项目配置文件
21
- const config = require('../config/index');
22
+ const projectConfig = require('../config/index');
22
23
  const getBaseWebpackConfig = require('./webpack.base.conf');
23
24
 
24
- module.exports = () => {
25
+ module.exports = (akfunConfig) => {
26
+ let config = akfunConfig || projectConfig; // 默认使用执行命令目录下的配置数据
25
27
  const curEnvConfig = config.build || {}; // 当前执行环境配置
26
28
  // 获取webpack基本配置
27
29
  const baseWebpackConfig = getBaseWebpackConfig(curEnvConfig);
@@ -175,6 +177,11 @@ module.exports = () => {
175
177
  })
176
178
  );
177
179
  }
180
+
181
+ // 是否开启
182
+ if (curEnvConfig.openMonacoWebpackPlugin) {
183
+ webpackProdConfig.plugins.push(new MonacoWebpackPlugin());
184
+ }
178
185
 
179
186
  if (curEnvConfig.bundleAnalyzerReport) {
180
187
  webpackProdConfig.plugins.push(new BundleAnalyzerPlugin());