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()
})
]
}cnpm install html-webpack-plugin --save-dev
<!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>
本文出自 “素颜” 博客,请务必保留此出处http://suyanzhu.blog.51cto.com/8050189/1899515
原文:http://suyanzhu.blog.51cto.com/8050189/1899515