akfun 3.0.2 → 3.0.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.2",
3
+ "version": "3.0.3",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
@@ -112,6 +112,7 @@
112
112
  "http-proxy-middleware": "^2.0.2",
113
113
  "inquirer": "^8.2.0",
114
114
  "mini-css-extract-plugin": "^2.5.3",
115
+ "css-minimizer-webpack-plugin": "^3.4.1",
115
116
  "monaco-editor-webpack-plugin": "6.0.0",
116
117
  "sass": "^1.49.7",
117
118
  "open": "^8.4.0",
@@ -58,7 +58,6 @@
58
58
  "webpack-dev-middleware": "^3.7.2",
59
59
  "webpack-hot-middleware": "^2.25.0",
60
60
  "webpack-merge": "^4.2.2",
61
- "url-loader": "^4.1.0",
62
61
  "vue-loader": "^15.9.2",
63
62
  "vue-style-loader": "^4.1.2",
64
63
  "vue-template-compiler": "^2.6.11",
@@ -73,7 +72,6 @@
73
72
  "http-proxy-middleware": "^1.0.4",
74
73
  "autoprefixer": "^9.8.0",
75
74
  "mini-css-extract-plugin": "^0.9.0",
76
- "file-loader": "^6.0.0",
77
75
  "optimize-css-assets-webpack-plugin": "^5.0.3",
78
76
  "params-replace-loader": "^1.1.6",
79
77
  "progress-bar-webpack-plugin": "^2.1.0",
@@ -98,7 +98,6 @@
98
98
  "eventsource-polyfill": "^0.9.6",
99
99
  "express": "^4.17.2",
100
100
  "figlet": "^1.5.2",
101
- "file-loader": "^6.2.0",
102
101
  "git-clone": "^0.2.0",
103
102
  "glob": "^7.2.0",
104
103
  "html-loader": "^3.1.0",
@@ -135,7 +134,6 @@
135
134
  "ts-import-plugin": "^2.0.0",
136
135
  "ts-loader": "^9.2.6",
137
136
  "typescript": "^4.5.5",
138
- "url-loader": "^4.1.1",
139
137
  "vue-eslint-parser": "^8.2.0",
140
138
  "vue-loader": "^15.9.8",
141
139
  "vue-style-loader": "^4.1.3",
@@ -36,7 +36,20 @@ exports.cssLoaders = function (options) {
36
36
  const cssLoader = {
37
37
  loader: 'css-loader',
38
38
  options: {
39
- url: false, // enables/disables url()/image-set() functions handling
39
+ // url: false, // enables/disables url()/image-set() functions handling
40
+ url: {
41
+ filter: (url, resourcePath) => {
42
+ /*// 自定义配置优先
43
+ if (options.cssLoaderUrl !== undefined) {
44
+ return options.cssLoaderUrl;
45
+ }*/
46
+ // Don't handle `node_modules` urls
47
+ if (resourcePath.includes('node_modules')) {
48
+ return true;
49
+ }
50
+ return false;
51
+ },
52
+ },
40
53
  sourceMap: options.sourceMap
41
54
  }
42
55
  };
@@ -121,28 +121,43 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
121
121
  url-loader 功能类似于 file-loader,在文件大小(单位 byte)低于指定的限制时,可以返回一个 DataURL。
122
122
  */
123
123
  test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
124
- loader: 'url-loader',
125
- options: {
126
- limit: 10000,
127
- name: utils.assetsPath('img/[name].[hash:7].[ext]')
124
+ type: 'asset',
125
+ parser: {
126
+ dataUrlCondition: {
127
+ maxSize: 2 * 1024 //data转成url的条件,也就是转成bas64的条件,maxSize相当于limit
128
+ }
129
+ },
130
+ generator: {
131
+ // filename,和output中设置assetModuleFilename一样,将资源打包至img文件夹
132
+ filename: utils.assetsPath('img/[name].[hash:7][ext]') //[name]指原来的名字,[hash:6]取哈希的前六位,[ext]指原来的扩展名
128
133
  }
129
134
  },
130
135
  {
131
136
  // 视频音频资源
132
137
  test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
133
- loader: 'url-loader',
134
- options: {
135
- limit: 10000,
136
- name: utils.assetsPath('media/[name].[hash:7].[ext]')
138
+ type: 'asset',
139
+ parser: {
140
+ dataUrlCondition: {
141
+ maxSize: 2 * 1024 //data转成url的条件,也就是转成bas64的条件,maxSize相当于limit
142
+ }
143
+ },
144
+ generator: {
145
+ // filename,和output中设置assetModuleFilename一样,将资源打包至imgs文件夹
146
+ filename: utils.assetsPath('media/[name].[hash:7][ext]') //[name]指原来的名字,[hash:6]取哈希的前六位,[ext]指原来的扩展名
137
147
  }
138
148
  },
139
149
  {
140
150
  // 字体资源
141
151
  test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
142
- loader: 'url-loader',
143
- options: {
144
- limit: 10000,
145
- name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
152
+ type: 'asset',
153
+ parser: {
154
+ dataUrlCondition: {
155
+ maxSize: 2 * 1024 //data转成url的条件,也就是转成bas64的条件,maxSize相当于limit
156
+ }
157
+ },
158
+ generator: {
159
+ // filename,和output中设置assetModuleFilename一样,将资源打包至fonts目录中
160
+ filename: utils.assetsPath('fonts/[name].[hash:7][ext]') //[name]指原来的名字,[hash:6]取哈希的前六位,[ext]指原来的扩展名
146
161
  }
147
162
  },
148
163
  {
@@ -7,7 +7,7 @@ const projectConfig = require('../config/index');
7
7
  const getBaseWebpackConfig = require('./webpack.base.conf');
8
8
  const entrys2htmlWebpackPlugin = require('../utils/entrys2htmlWebpackPlugin');
9
9
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
10
- // const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
10
+ // const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
11
11
 
12
12
  module.exports = (akfunConfig) => {
13
13
  let config = akfunConfig || projectConfig; // 默认使用执行命令目录下的配置数据
@@ -1,6 +1,6 @@
1
1
  const { merge } = require('webpack-merge');
2
- // const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
3
2
  const MiniCssExtractPlugin = require('mini-css-extract-plugin'); // 替换extract-text-webpack-plugin
3
+ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
4
4
  const CompressionWebpackPlugin = require('compression-webpack-plugin');
5
5
  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
6
6
 
@@ -42,7 +42,12 @@ module.exports = (akfunConfig) => {
42
42
  */
43
43
  chunkIds: 'named',
44
44
  emitOnErrors: true,
45
- minimize: true
45
+ minimize: true,
46
+ minimizer: [
47
+ // For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
48
+ `...`,
49
+ new CssMinimizerPlugin()
50
+ ]
46
51
  },
47
52
  plugins: [
48
53
  new MiniCssExtractPlugin({
@@ -3,8 +3,8 @@ const path = require('path');
3
3
  const { merge } = require('webpack-merge');
4
4
  const CopyWebpackPlugin = require('copy-webpack-plugin');
5
5
  // const ExtractTextPlugin = require('extract-text-webpack-plugin'); // 不支持webpack4.0
6
- // const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
7
6
  const MiniCssExtractPlugin = require('mini-css-extract-plugin'); // 替换extract-text-webpack-plugin
7
+ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
8
8
  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
9
9
  const CompressionWebpackPlugin = require('compression-webpack-plugin');
10
10
  const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
@@ -71,7 +71,12 @@ module.exports = (akfunConfig) => {
71
71
  }
72
72
  }
73
73
  },
74
- minimize: true
74
+ minimize: true,
75
+ minimizer: [
76
+ // For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
77
+ `...`,
78
+ new CssMinimizerPlugin()
79
+ ]
75
80
  },
76
81
  plugins: [
77
82
  new MiniCssExtractPlugin({