Vue Cli 3.0 配置文件在哪里?

Vue Cli 3.0 where is the config file?

我在文档等 vue.config.js 文件中看到过它。 并且之前还注意到这些是在 2.0 中的 webpack 配置文件等中处理的。 但是我在用 vue cli 3.0 创建的项目文件夹中找不到任何一个文件...配置文件在哪里,为什么它不在顶级文件夹等的任何地方?

Where is the config files and why isn't it anywhere in the top level folders, etc?

初始项目不需要文件存在,因为您刚刚使用不需要任何配置的全新 "default" 设置创建了一个项目。

自己创造吧。它甚至在 README:

中被提及

Many aspects of a Vue CLI project can be configured by placing a vue.config.js file at the root of your project. The file may already exist depending on the features you selected when creating the project.

(强调我的)

编辑:现在可在此处找到:https://cli.vuejs.org/config/#global-cli-config

不再需要 "config" 目录。 如果你想定义 "environment variables" 你可以在“.env”文件中定义

就像:

VUE_APP_TITLE=Test

您还可以为每个环境创建“.env”文件

喜欢:

.env.development 开发模式

.env.production 用于生产模式。

更多信息请阅读: https://cli.vuejs.org/guide/mode-and-env.html#example-staging-mode

vue.config.js 现在是一个可选的配置文件。

参考:https://cli.vuejs.org/config/#vue-config-js

该文件默认 不存在 正如 Linus 提到的那样。您需要在项目的根位置手动创建 vue.config.js 文件,即在 package.json.

的同一级别

看看这个:

  1. 创建

vue.config.js

在你的vue项目中与

同级

package.json

  1. 指定主机和端口:module.exports = { devServer: { host: "localhost", port: "8080" } }

  2. 运行:

npm run serve

在你的 vue 文件夹中。

查看此屏幕截图: Hope it helps!

PS:如果您想禁用 运行 本地主机上的应用程序,请查看此 post: