更改vue-cli3中的
在 vue.config.js 的文件中加入下面这段话
// vue.config.js
const Timestamp = new Date().getTime();
module.exports = {
configureWebpack: { // webpack 配置
output: { // 输出重构 打包编译后的 文件名称 【模块名称.版本号.时间戳】
filename: `[name].${process.env.VUE_APP_Version}.${Timestamp}.js`,
chunkFilename: `[name].${process.env.VUE_APP_Version}.${Timestamp}.js`
},
},
}
更改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')
}
在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">
还需要在Nginx中设置