一、运行 npm install html-webpack-plugin –D 命令,安装生成预览页面的插件
二、 修改 webpack.config.js 文件头部区域,配置如下信息:
const path
= require('path');
const HtmlWebpackPlugin
= require('html-webpack-plugin');
const htmlPlugin
= new HtmlWebpackPlugin({
template
: './src/index.html',
filename
: 'index.html'
})
module
.exports
= {
mode
: 'development',
entry
: path
.join(__dirname
, './src/index.js'),
output
: {
path
: path
.join(__dirname
, './dist'),
filename
: 'bundle.js'
},
plugins
: [htmlPlugin
]
}
三、运行 npm run dev
四、访问http://localhost:8080/,预览页面为index.html的页面
转载请注明原文地址:https://ipadbbs.8miu.com/read-54890.html