1. vue.config.js
const currentTime = () => {
return new Date().toLocaleDateString().replace(/\//g, '-') + ' ' + time.toTimeString().substr(0, 8); // 2018-5-18 00:00:00
};
module.exports = {
chainWebpack: (config) => {
config.plugin('html').tap((args) => {
args[0].minify = false;
args[0].PACK_TIME = currentTime(); // 当前时间
return args;
});
},
}
2. index.html 配置
<!DOCTYPE html>
<!-- PACK_TIME就是打包的时间 -->
<html update="<%= htmlWebpackPlugin.options.PACK_TIME %>">
<head>
</head>
<body>
<div id="app"></div>
</body>
</html>