akfun 2.0.1 → 2.0.2

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": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
@@ -15,7 +15,7 @@ const catchVuePages = require('../utils/catchVuePages'); // 用于获取当前
15
15
  // 引入当前项目配置文件
16
16
  const projectConfig = require('../config/index');
17
17
  const babelConfig = require('../config/babel.config'); // Babel的配置文件
18
- const {buildBanner} = require("../utils/akfunParams");
18
+ const { buildBanner } = require('../utils/akfunParams');
19
19
  const getJsEntries = require('../utils/jsEntries');
20
20
  const { isArray } = require('../utils/typeof');
21
21
 
@@ -58,9 +58,12 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
58
58
  */
59
59
  resolve: curWebpackConfig.resolve,
60
60
  externals: curWebpackConfig.ignoreNodeModules
61
- ? [nodeExternals({
62
- allowlist: curWebpackConfig.allowList ? curWebpackConfig.allowList : []
63
- })].concat(curWebpackConfig.externals)
61
+ ? [
62
+ nodeExternals({
63
+ importType: 'commonjs',
64
+ allowlist: curWebpackConfig.allowList ? curWebpackConfig.allowList : []
65
+ })
66
+ ].concat(curWebpackConfig.externals)
64
67
  : curWebpackConfig.externals,
65
68
  module: {
66
69
  rules: [
@@ -166,9 +169,14 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
166
169
  if (curEnvConfig.ignoreNodeModules !== undefined) {
167
170
  const allowList = curEnvConfig.allowList || curWebpackConfig.allowList;
168
171
  const externals = curEnvConfig.externals || config.webpack.external || [];
169
- webpackConfig.externals = curEnvConfig.ignoreNodeModules ? [nodeExternals({
170
- allowlist: allowList || [],
171
- })].concat(externals) : externals;
172
+ webpackConfig.externals = curEnvConfig.ignoreNodeModules
173
+ ? [
174
+ nodeExternals({
175
+ importType: 'commonjs',
176
+ allowlist: allowList || []
177
+ })
178
+ ].concat(externals)
179
+ : externals;
172
180
  }
173
181
  // 集成构建入口相关的配置(优先级更高)
174
182
  if (curEnvConfig.entry) {
@@ -37,7 +37,8 @@ module.exports = (akfunConfig) => {
37
37
  emitOnErrors: true,
38
38
  splitChunks: {
39
39
  cacheGroups: {
40
- defaultVendors: { // 4.0: vendors
40
+ defaultVendors: {
41
+ // 4.0: vendors
41
42
  test: /node_modules\/(.*)/,
42
43
  name: 'vendor',
43
44
  chunks: 'initial',
@@ -55,7 +56,7 @@ module.exports = (akfunConfig) => {
55
56
  },
56
57
  plugins: [
57
58
  // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
58
- new webpack.HotModuleReplacementPlugin(),
59
+ new webpack.HotModuleReplacementPlugin()
59
60
  ]
60
61
  });
61
62
 
@@ -68,7 +69,7 @@ module.exports = (akfunConfig) => {
68
69
  // 开启热更新能力
69
70
  const devClientPath = path.resolve(__dirname, '../dev-client'); // 从akfun中获取
70
71
  // add hot-reload related code to entry chunks
71
- if (webpackDevConfig.entry) {
72
+ if (!curEnvConfig.closeHotReload && webpackDevConfig.entry) {
72
73
  Object.keys(webpackDevConfig.entry).forEach((name) => {
73
74
  webpackDevConfig.entry[name] = [devClientPath].concat(webpackDevConfig.entry[name]);
74
75
  });
@@ -23,10 +23,10 @@ module.exports = (akfunConfig) => {
23
23
  publicPath: '',
24
24
  library: {
25
25
  type: 'umd', // 定义打包方式Universal Module Definition,同时支持在CommonJS、AMD和全局变量使用
26
- name: curEnvConfig.libraryName,
26
+ name: curEnvConfig.libraryName
27
27
  },
28
28
  // 指定类库名,主要用于直接引用的方式(比如使用script 标签)
29
- globalObject: 'this', // 定义全局变量,兼容node和浏览器运行,避免出现"window is not defined"的情况
29
+ globalObject: 'this' // 定义全局变量,兼容node和浏览器运行,避免出现"window is not defined"的情况
30
30
  },
31
31
  module: {
32
32
  rules: utils.styleLoaders({
@@ -34,7 +34,7 @@ module.exports = (akfunConfig) => {
34
34
  environment: 'prod'
35
35
  })
36
36
  },
37
- devtool: curEnvConfig.productionSourceMap ? curEnvConfig.devtool || 'source-map' : false, // 线上生成环境
37
+ devtool: curEnvConfig.productionSourceMap ? curEnvConfig.devtool || 'source-map' : false, // 线上生成环境
38
38
  optimization: {
39
39
  /**
40
40
  * named 对调试更友好的可读的 id。
@@ -46,15 +46,15 @@ module.exports = (akfunConfig) => {
46
46
  plugins: [
47
47
  new MiniCssExtractPlugin({
48
48
  // filename: utils.assetsPath('index.css'),
49
- filename: "[name].css",
50
- chunkFilename: "[name].css",
49
+ filename: '[name].css',
50
+ chunkFilename: '[name].css',
51
51
  ignoreOrder: false
52
52
  }),
53
53
  new OptimizeCSSPlugin({
54
54
  cssProcessorOptions: {
55
55
  safe: true
56
56
  }
57
- }),
57
+ })
58
58
  ]
59
59
  });
60
60
 
@@ -55,7 +55,8 @@ module.exports = (akfunConfig) => {
55
55
  emitOnErrors: true,
56
56
  splitChunks: {
57
57
  cacheGroups: {
58
- defaultVendors: { // 4.0: vendors
58
+ defaultVendors: {
59
+ // 4.0: vendors
59
60
  test: /node_modules\/(.*)/,
60
61
  name: 'vendor',
61
62
  chunks: 'initial',
@@ -90,7 +91,7 @@ module.exports = (akfunConfig) => {
90
91
  cssProcessorOptions: {
91
92
  safe: true
92
93
  }
93
- }),
94
+ })
94
95
  ]
95
96
  });
96
97
 
@@ -128,7 +129,7 @@ module.exports = (akfunConfig) => {
128
129
  })
129
130
  );
130
131
  }
131
-
132
+
132
133
  // 是否开启
133
134
  if (curEnvConfig.openMonacoWebpackPlugin) {
134
135
  webpackProdConfig.plugins.push(new MonacoWebpackPlugin());