akfun 3.0.7 → 3.1.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.0.7",
3
+ "version": "3.1.3",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
package/src/dev-server.js CHANGED
@@ -115,21 +115,21 @@ module.exports = function (akfunConfig, _consoleTag) {
115
115
  const uri = `http://${config.dev.hostname}:${port}`;
116
116
 
117
117
  console.log(`> Listening at ${uri}\n`);
118
- // 如果是开发环境,自动打开浏览器并跳到项目首页
118
+ spinner.succeed(`${consoleTag}调试模式已开启!`);
119
+ // 打印当前环境中的首个html和css地址
120
+ const projPath = `${uri}${webpackConfig.output.publicPath}`;
121
+ let entryConfig = webpackConfig.entry || {}; // 获取构建入口配置
122
+ const entryFiles = (entryConfig && Object.keys(entryConfig)) || [];
123
+ if (entryFiles.length > 0) {
124
+ // 获取第一个入口文件
125
+ const filename = entryFiles[0];
126
+ console.info(
127
+ `当前运行脚本:\n ${projPath}${filename}.js\n当前运行样式[可能不存在]:\n${projPath}${filename}.css`
128
+ );
129
+ }
130
+ // 是否自动打开浏览器并跳到项目首页
119
131
  if (autoOpenBrowser) {
120
- spinner.succeed(`${consoleTag}调试模式已开启!`);
121
- // 打印当前环境中的首个html和css地址
122
- const projPath = `${uri}${webpackConfig.output.publicPath}`;
123
- let entryConfig = webpackConfig.entry || {}; // 获取构建入口配置
124
- const entryFiles = (entryConfig && Object.keys(entryConfig)) || [];
125
- if (entryFiles.length > 0) {
126
- // 获取第一个入口文件
127
- const filename = entryFiles[0];
128
- console.info(
129
- `当前运行脚本:\n ${projPath}${filename}.js\n当前运行样式[可能不存在]:\n${projPath}${filename}.css`
130
- );
131
- open(`${projPath}${filename}.html`, { wait: true });
132
- }
132
+ open(`${projPath}${filename}.html`, { wait: true });
133
133
  }
134
134
  server = app.listen(port);
135
135
  _resolve();
@@ -193,7 +193,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
193
193
  // 优先使用执行环境中的配置
194
194
  if (curEnvConfig.ignoreNodeModules !== undefined) {
195
195
  const allowList = curEnvConfig.allowList || curWebpackConfig.allowList;
196
- const externals = curEnvConfig.externals || config.webpack.external || [];
196
+ const externals = curEnvConfig.externals || curWebpackConfig.external || [];
197
197
  webpackConfig.externals = curEnvConfig.ignoreNodeModules
198
198
  ? [
199
199
  nodeExternals({
@@ -305,5 +305,11 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
305
305
  );
306
306
  }
307
307
 
308
+ // 判断是否有自定义plugins
309
+ if (curWebpackConfig.plugins && Array.isArray(curWebpackConfig.plugins)) {
310
+ // 添加自定义webpack插件
311
+ webpackConfig.plugins.push(...curWebpackConfig.plugins);
312
+ }
313
+
308
314
  return webpackConfig;
309
315
  };
@@ -52,11 +52,13 @@ module.exports = (akfunConfig) => {
52
52
  ]
53
53
  });
54
54
 
55
- // 使用用户自定义的多入口配置,生产对应的多页面多模板(优先使用用户的自定义页面模板)
56
- const htmlWebpackPluginList = entrys2htmlWebpackPlugin(webpackDevConfig.entry, curHtmlTemplate);
57
- htmlWebpackPluginList.forEach((htmlWebpackPlugin) => {
58
- webpackDevConfig.plugins.push(htmlWebpackPlugin);
59
- });
55
+ if (!webpackDevConfig.closeHtmlWebpackPlugin) {
56
+ // 使用用户自定义的多入口配置,生产对应的多页面多模板(优先使用用户的自定义页面模板)
57
+ const htmlWebpackPluginList = entrys2htmlWebpackPlugin(webpackDevConfig.entry, curHtmlTemplate);
58
+ htmlWebpackPluginList.forEach((htmlWebpackPlugin) => {
59
+ webpackDevConfig.plugins.push(htmlWebpackPlugin);
60
+ });
61
+ }
60
62
 
61
63
  // 开启热更新能力
62
64
  const devClientPath = path.resolve(__dirname, '../dev-client'); // 从akfun中获取