Vue Cli 3.0配置文件在哪里?

vue.js Vue.js

JimHarry

2020-03-11

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

第630篇《Vue Cli 3.0配置文件在哪里?》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

4个回答
阿飞猿 2020.03.11

不再需要“ config”目录。如果要定义“环境变量”,则可以在“ .env”文件中执行此操作

就像:

VUE_APP_TITLE=Test

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

喜欢:

.env.development 用于开发模式

.env.production 用于生产模式。

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

Eva理查德 2020.03.11

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

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

宝儿Near 2020.03.11

配置文件在哪里,为什么不在顶级文件夹等中的任何地方?

初始项目不需要文件存在,因为您刚刚创建了一个项目,该项目具有不需要任何配置的全新“默认”设置。

自己创建。自述文件中甚至提到了它

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.

(emphasis mine)

Edit: now to be found here: https://cli.vuejs.org/config/#global-cli-config

达蒙逆天Pro 2020.03.11

默认情况下,该文件存在,如Linus所提到的。您需要vue.config.js在项目的根位置(即在的同一级别)上手动创建文件package.json

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android