akfun 3.2.3 → 3.2.7

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.2.3",
3
+ "version": "3.2.7",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
@@ -155,6 +155,7 @@
155
155
  "webpack-hot-middleware": "^2.25.1",
156
156
  "webpack-merge": "^5.8.0",
157
157
  "webpack-node-externals": "^3.0.0",
158
+ "@svgr/webpack": "^6.2.1",
158
159
  "yargs": "^12.0.5"
159
160
  },
160
161
  "devDependencies": {
package/src/build.js CHANGED
@@ -3,7 +3,7 @@ const rm = require('rimraf');
3
3
  const path = require('path');
4
4
  const chalk = require('chalk');
5
5
  const webpack = require('webpack');
6
- const {curConsoleTag} = require("./utils/akfunParams");
6
+ const { curConsoleTag } = require('./utils/akfunParams');
7
7
  const checkVersion = require('./check-versions');
8
8
  const projectConfig = require('./config/index'); // 引入当前项目配置文件
9
9
  const defaultConfig = require('./config/default.config');
@@ -17,6 +17,7 @@ module.exports = function (BuildType, akfunConfig, _consoleTag) {
17
17
  // 参数中的config配置优先级最高
18
18
  config = deepMergeConfig(defaultConfig, akfunConfig);
19
19
  }
20
+ let curEnvConfig = config.build;
20
21
  // 检查当前npm版本号是否匹配
21
22
  checkVersion();
22
23
  const spinner = ora(`${consoleTag}开始构建...`).start();
@@ -26,6 +27,7 @@ module.exports = function (BuildType, akfunConfig, _consoleTag) {
26
27
  if (BuildType && BuildType === 'lib') {
27
28
  spinner.start(`${consoleTag}开始构建lib库...`);
28
29
  webpackConfig = require('./webpack/webpack.library.conf')(config);
30
+ curEnvConfig = config.build2lib;
29
31
  } else {
30
32
  spinner.start(`${consoleTag}开始构建生产环境的代码...`);
31
33
  webpackConfig = require('./webpack/webpack.prod.conf')(config);
@@ -36,10 +38,10 @@ module.exports = function (BuildType, akfunConfig, _consoleTag) {
36
38
  * 使用 config.dev.NODE_ENV 作为当前的环境
37
39
  */
38
40
  if (!process.NODE_ENV) {
39
- process.NODE_ENV = config.build.NODE_ENV; // 将运行环境设置为生产环境
41
+ process.NODE_ENV = curEnvConfig.NODE_ENV; // 将运行环境设置为生产环境
40
42
  }
41
43
 
42
- rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), (err) => {
44
+ rm(path.join(curEnvConfig.assetsRoot, curEnvConfig.assetsSubDirectory), (err) => {
43
45
  if (err) throw err;
44
46
  webpack(webpackConfig, (err, stats) => {
45
47
  spinner.stop();
@@ -122,6 +122,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
122
122
  */
123
123
  test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
124
124
  type: 'asset',
125
+ issuer: /\.s?css$/,
125
126
  parser: {
126
127
  dataUrlCondition: {
127
128
  maxSize: 2 * 1024 //data转成url的条件,也就是转成bas64的条件,maxSize相当于limit
@@ -132,6 +133,11 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
132
133
  filename: utils.assetsPath('img/[name].[hash:7][ext]') //[name]指原来的名字,[hash:6]取哈希的前六位,[ext]指原来的扩展名
133
134
  }
134
135
  },
136
+ {
137
+ test: /\.svg$/,
138
+ issuer: /\.[jt]sx?$/,
139
+ use: ['@svgr/webpack']
140
+ },
135
141
  {
136
142
  // 视频音频资源
137
143
  test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
@@ -311,5 +317,11 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
311
317
  webpackConfig.plugins.push(...curWebpackConfig.plugins);
312
318
  }
313
319
 
320
+ // 判断是否有自定义loader
321
+ if (curWebpackConfig.moduleRules && Array.isArray(curWebpackConfig.moduleRules)) {
322
+ // 添加自定义自定义loader
323
+ webpackConfig.module.rules.push(...curWebpackConfig.moduleRules);
324
+ }
325
+
314
326
  return webpackConfig;
315
327
  };