
1、找到/build/webpack.dev.conf.js新增配置,运行项目用到
```js
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
node_env_dev: true, // 新增配置
inject: true,
favicon: path.resolve('./static/favicon.ico')
}),
```
2、找到/build/webpack.prod.conf.js新增配置,打包项目用到
```js
new HtmlWebpackPlugin({
filename: config.build.index,
template: 'index.html',
inject: true,
node_env_prod: true, // 新增配置
version_time: new Date().getTime(), // 配置打包后config.js文件,加时间戳
...
}),
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*','config.js'] // 忽略掉 config.js 文件的复制
},
// 复制配置文件到根路径下
{
from: path.join(__dirname,'../static/config.js')
}
])
```
3、找到需要配置的页面index.html
//判断运行配置文件的引用路径,使打包后正常引用。
```?v=<%=htmlWebpackPlugin.options.version_time%>``` 对引入文件加时间戳
```html
<% if ( htmlWebpackPlugin.options.node_env_prod ) { %> <% } %>
<% if ( htmlWebpackPlugin.options.node_env_dev ) { %> <% } %>
```
运行vue函数提示将“vue”项识别为 cmdlet、函数、脚本文件或可运行程序的名称解决方法
上面是“vuejs实现全站可配置”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_1634.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

手游《王者荣耀》中的西施最强出装推荐(2024年最新版)
ComfyUI绘画生成提示“conv_in.weight”错误解决方法
快手PC版
飞鱼视频下载助手:支持国内外大部分视频网站的解析,支持超多视频格式,极速下载
百度echarts如何做一个3D地图线路流向图