{
"name": "demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"html-webpack-plugin": "^4.0.3",
"webpack": "^3.12.0"
}
}
const HtmpWebpackPlugin=require('html-webpack-plugin');
const path=require('path');
module.exports={
entry: './src/main.js',
output:{
path: path.resolve(__dirname,'dist'),
filename: 'app.js'
},
plugins:[
new HtmpWebpackPlugin()
]
}
同样可以指定html模板和文件名进行编译,在配置中修改如下:
new HtmpWebpackPlugin({
filename: 'app.html',
template: './src/index.html'
})