
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,我们会在看到邮件的第一时间内为您处理!

 Data Formulator
 gooood谷德设计网官网首页入口
 盘点世界上最不喜欢中国的七个国家和最喜欢中国的七个国家?
 推荐一款高质量、免费可商用插画网站——Manypixels Free Illustrations
 一个提供高质量的免版税图片/插画/视频和音频素材的网站——DreamsTime