Vue/cli2.x版本更新清除浏览器缓存

2022-05-05 20:10:20 浏览数 (1)

修改build/webpack.prod.conf.js路径里的文件

代码语言:javascript复制
const version = new Date().getTime();
output: {
  path: config.build.assetsRoot,
    filename: utils.assetsPath('js/[name].[chunkhash:8].'   version   '.js'),
    chunkFilename: utils.assetsPath('js/[name].[chunkhash:8].'   version   '.js')
},

 new HtmlWebpackPlugin({
      filename: process.env.NODE_ENV === 'testing' ?
        'index.html' :
        config.build.index,
      template: 'index.html',
      inject: true,
      hash: version,
      minify: {
        removeComments: true,
        collapseWhitespace: true,
        removeAttributeQuotes: true
        // more options:
        // https://github.com/kangax/html-minifier#options-quick-reference
      },
      // necessary to consistently work with multiple chunks via CommonsChunkPlugin
      chunksSortMode: 'dependency'
    }),

index.html页面

代码语言:javascript复制
 <meta http-equiv="pragram" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate">
 <meta name="viewport" content="width=device-width,initial-scale=1.0">

0 人点赞