----vue项目打包之浏览器存在缓存问题----

在入口文件index.html添加

<meta http-equiv="pragram" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="expires" content="0">

 

因浏览器缓存原因导致vue 打包后的文件不能即使更新最新代码。缓存里的内容没有清除。(基本没作用)

解决办法就是在打包的文件名中添加一个版本号以便浏览器能区分。

 

build--webpack .prod.conf.js

const  Version = new Date().getTime(); //定义一个时间作为版本号。

 output: {
    path: config.build.assetsRoot,
    filename: utils.assetsPath('js/[name].[chunkhash]'+ Version+'.js'),
    chunkFilename: utils.assetsPath('js/[id].[chunkhash]'+Version +'.js')
  }

posted @ 2019-07-08 22:02  BenSan、  阅读(5331)  评论(2编辑  收藏  举报