Install both packages
Use npm install webpack-dev-server html-webpack-plugin
webpack.config.js configuration file to add html-webpack-plugin plugin
...
const HtmlWebpackPlugin = require('html-webpack-plugin');
const htmlWebpackPlugin = new HtmlWebpackPlugin({
template: 'path/to/file.html', // 输入文件
filename: 'path/to/file.html', // 输出文件
});
module.exports = {
...
plugins: [
htmlWebpackPlugin // 添加插件
],
...
}
webpack-dev-server command, add script commands in the package file.
--host x.x.x.x // 启动的ip地址
--port 3000 // 监听的端口号