1.首先在vue.config.js中写如下代码
const currentTime = () => {
return new Date().toLocaleString();
};
module.exports = {
chainWebpack(config) {
config.plugin('html').tap((args) => {
args[0].minify = false;
args[0].PACK_TIME = currentTime(); // 打包当前时间
return args;
});
}
}
2.index.html中的html根标签上写 update="<%= htmlWebpackPlugin.options.PACK_TIME %>"
<html update="<%= htmlWebpackPlugin.options.PACK_TIME %>">
3.打包后上传服务器,审查元素,就能在html中看到。