108.在htmlWebpackPlugin中使用date,修改webpack.config.js文件
var htmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry:{
main:'./src/script/main.js',
a:'./src/script/a.js'
},
output:{
path:'./dist',
filename:'js/[name]-[hash].js'
},
plugins:[
new htmlWebpackPlugin({
template:'index.html',
filename:'index-[hash].html',
inject:'head',
date:new Date()
})
]
}
109.安装html-webpack-plugin插件
cnpm install html-webpack-plugin --save-dev
110.修改模板文件index.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>webpack demo</title> <link rel="stylesheet" href=""> </head> <body> <%= htmlWebpackPlugin.options.date %> </body> </html>
111.使用cnpm run webpack命令重新打包
本文转自 素颜猪 51CTO博客,原文链接:http://blog.51cto.com/suyanzhu/1899515