https://www.npmjs.com/package/html-webpack-plugin
webpack多页应用架构系列(十二):利用webpack生成HTML普通网页&页面模板
生成html文件并 绑定 js
yarn add --dev html-webpack-plugin
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: 'index.js',
output: {
path: __dirname + '/dist',
filename: 'index_bundle.js'
},
plugins: [
new HtmlWebpackPlugin(
template: './src/index.html'
)
]
}
name | default | type |
---|---|---|
title | '' | |
filename | 'index.html' | |
template | '' | |
inject | true(body) | 注入的位置 body head |
xhtml | false | 闭合link标签 |
minify | true | |
hash | false | index.js -> index.123154646 |
//使用 ejs
<%= htmlWebpackPlugin.options.hello %>
网友评论