文件结构
.
├── index.js
├── package.json
├── tpl.html
├── webpack.config.js
└── ...
webpack.config.js
const Html = require('html-webpack-plugin');
module.exports = {
mode : 'development',
entry : './index.js',
output : {
filename : 'bundle.js',
path : __dirname + '/dist',
},
plugins : [
new Html({
template : './tpl.html',
}),
],
};
package.json
{
"scripts": {
"start": "npx webpack-dev-server --open"
},
"devDependencies": {
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.28.1",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.14"
}
...
}
登录后评论