vue多頁面熱更新等待時間長解決方案


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM