【问题标题】:Vue Cli 3 vue.config.js no autoOpenBrowser optionVue Cli 3 vue.config.js 没有 autoOpenBrowser 选项
【发布时间】:2018-12-05 19:12:36
【问题描述】:

我使用 @vue/cli 3 创建了一个项目并尝试添加 autoOpenBrowser 选项并收到以下错误。所以,我猜这个选项不再可用?

错误 WebpackDevServerOptionsValidationError:配置对象无效。 webpack-dev-server 已使用与 API 模式不匹配的配置对象进行初始化。 - 配置具有未知属性“autoOpenBrowser”。这些属性是有效的: object { hot?, hotOnly?, lazy?, bonjour?, host?, allowedHosts?, filename?, publicPath?, port?, socket?, watchOptions?, headers?, logLevel?, clientLogLevel?, overlay?, progress?, key?, cert?, ca?, pfx?, pfxPassphrase?, requestCert?, inline?, disableHostCheck?, public?, https?, contentBase?, watchContentBase?, open?, useLocalIp?, openPage?, features?, compress? , proxy?, historyApiFallback?, staticOptions?, setup?, before?, after?, stats?, report?, logTime?, noInfo?, quiet?, serverSideRender?, index?, log?, warn? }

module.exports = {
  devServer: {
    port: 4020,
    autoOpenBrowser: true
  }
}

【问题讨论】:

    标签: vue.js vue-cli


    【解决方案1】:

    在根级别创建 vue.config.js 文件并将您的代码添加到此文件中。运行命令 npm run serve 将自动在浏览器中打开您的应用程序。

    module.exports = {
      devServer: {
        port: 8080,
        open: true
      }
    }
    

    【讨论】:

      【解决方案2】:

      Duh,这是开放选项...我将 config/index.js 文件与 webpack.config.js 混淆了。

      module.exports = {
        devServer: {
          port: 4020,
          open: true
        }
      }
      

      【讨论】:

        猜你喜欢
        • 2020-02-08
        • 2019-03-25
        • 2020-03-12
        • 2019-04-08
        • 1970-01-01
        • 2019-12-17
        • 2022-01-14
        • 2019-04-05
        相关资源
        最近更新 更多