【问题标题】:ERROR Invalid options in vue.config.js: "build" is not allowed. "dev" is not allowed错误 vue.config.js 中的选项无效:不允许“构建”。 “开发”是不允许的
【发布时间】:2018-09-23 05:10:40
【问题描述】:

我有一个现有的vue-cli 2 应用程序,我正在尝试升级到vue-cli-3。添加我的唯一依赖项后,我将src/ 直接放入新创建的vue-cli-3 应用程序并启动。 哇!

既然我们使用vue.config.js,我该如何管理[PROD|DEV|TEST].env.js

我收到以下错误,因为我第一次尝试创建vue.config.js 只是将config/index.js 重命名为/vue.config.js 并保留现有的/config/[PROD|DEV|TEST].env.js,但我收到以下错误:

ERROR  Invalid options in vue.config.js: "build" is not allowed. "dev" 
is not allowed error Command failed with exit code 1.

我不明白现在如何管理环境。

感谢您的宝贵时间!

【问题讨论】:

    标签: vue.js vue-cli


    【解决方案1】:

    也许你应该改用devServer。而对于build,我想现在还有另一个名字。

    例如:

    module.exports = {
      devServer: {
       // your settings
      }
    }
    

    例如:

    module.exports = {
      devServer: {
        proxy: {
          '/api': {
            target: '<url>',
            ws: true,
            changeOrigin: true
          },
          '/foo': {
            target: '<other_url>'
          }
        }
      }
    }
    

    参考:vue-cli

    【讨论】:

    • 太棒了!解决了我的问题,我的端口变量设置在 vue.config
    猜你喜欢
    • 2016-01-18
    • 1970-01-01
    • 2020-04-19
    • 2019-03-09
    • 2014-12-13
    • 2015-12-20
    • 1970-01-01
    • 1970-01-01
    • 2022-11-08
    相关资源
    最近更新 更多