https://www.webpackjs.com/guides/
截止到2020/07/24还存在的错误
(一)(管理输出部分)清理dist文件夹无用文件的插件:
clean-webpack-plugin
引用地址:https://www.jianshu.com/p/0e99366ce796
使用步骤:
cnpm install clean-webpack-plugin --save-dev
在webpack.config.js配置文件中
const {CleanWebpackPlugin} = require(‘clean-webpack-plugin‘);
plugins: [ new CleanWebpackPlugin()
... ],
(二)(代码分离部分)防止重复,将一些公用的插件提取出来单独打包:
CommonsChunkPlugin
使用步骤:不需要cnpm安装
在webpack.config.js配置文件中
const webpack = require(‘webpack‘); optimization: { splitChunks: { cacheGroups: { commons: { name: "commons", chunks: "initial", minChunks: 2 } } } }
but,里面各项参数变复杂了....