vue项目中,使用webpack配置进行在localhost下默认进入index.html页面的配置
使用html-webpack-plugin将src的index页面复制到根目录中并可以默认打开
- 运行npm install html-webpack-plugin -D 命令,安装生产预览页面的插件
- 修改webpack.config.js文件头部区域,添加如下配置信息:
//导入生成预览页面的插件
const HtmlWebpackPlugin = require('html-webpack-plugin')
const htmlplugin = new HtmlWebpackPlugin ({
template:'./src/index.html',//指定要用到的模板文件
filename:'index.html' //指定生成的文件的名称,该文件存在于内存中,在目录中不显示
})
- 修改webpack.config.js文件中向外暴露的配置对象,新增plugins节点
module.exports={
//plugin数组是webpack打包期间用到的插件列表
plugins: [ htmlplugin ]
}