1、使用html-webpack-plugin-for-multihtml組件。
在build - webpack.dev.conf.js文件中:
const HtmlWebpackPlugin = require('html-webpack-plugin')
替換為
const HtmlWebpackPlugin = require('html-webpack-plugin-for-multihtml')
2、multihtmlCache: true, // 解決多頁熱部署的關鍵 這里這里這里這里這里很重要!!!
for (var pathname in pages) { // 配置生成的html文件,定義路徑等 var conf = { filename: pathname + '.html', template: pages[pathname], // 模板路徑 inject: true, // js插入位置 multihtmlCache: true, // 解決多頁熱部署的關鍵 這里這里這里這里這里很重要!!! // necessary to consistently work with multiple chunks via CommonsChunkPlugin chunksSortMode: 'dependency' }; if (pathname in devWebpackConfig.entry) { conf.chunks = ['manifest','vendor', pathname]; conf.hash = false; } devWebpackConfig.plugins.push(new HtmlWebpackPlugin(conf)); }
如果對小哥哥小姐姐有幫助請點個推薦哈,歡迎留言、評論、搞事!! 雙肩背包 【正品折扣專業店】 -- biy1314.taobao.com