更新时间:2022-10-04 13:25:36
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:false, date:new Date(), }) ] }
<!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=""> <script type="text/javascript" src="<%= htmlWebpackPlugin.files.chunks.main.entry %>"></script> </head> <body> <script type="text/javascript" src="<%= htmlWebpackPlugin.files.chunks.a.entry %>"></script> </body> </html>
本文转自 素颜猪 51CTO博客,原文链接:http://blog.51cto.com/suyanzhu/1899570