首先确定你的build/webpack.dev.conf.js文件是不是有多个HtmlWebpackPlugin,代表多个页面入口,是的话才往下看哦
1.安装html-webpack-plugin-for-multihtml插件
npm i html-webpack-plugin-for-multihtml --save-dev
如果失败改成:cnpm i html-webpack-plugin-for-multihtml --save-dev
2.在build/webpack.dev.conf.js中修改:
const HtmlWebpackPlugin = require('html-webpack-plugin')
为
const HtmlWebpackPlugin = require('html-webpack-plugin-for-multihtml')
3.在所有HtmlWebpackPlugin中加缓存配置即可,可参考:http://www.yayihouse.com/yayishuwu/chapter/2730