简体   繁体   English

“vue.config.js”文件在哪里?

[英]Where is "vue.config.js" file?

I've just started to learn Vue but I simply can't set up enviroment for my container.我刚刚开始学习 Vue,但我根本无法为我的容器设置环境。 I use Cloud9 and I have to assign my host for serving Vue app according to this link .我使用 Cloud9,我必须根据此链接分配我的主机以服务 Vue 应用程序。

Unfortunately, I can't find vue.config.js file to do this.不幸的是,我找不到vue.config.js文件来执行此操作。

Also there is no path indication in Vue docs . Vue 文档中也没有路径指示。

"if it's present in your project root..." but what if not? "if it's present in your project root..."但如果没有呢? Whatever, go use React?无论如何,去使用 React? :) :)

Vue version: 3.1.1 Vue版本:3.1.1

See the documentation of Vue CLI :请参阅Vue CLI 的文档

vue.config.js is an optional config file that will be automatically loaded by @vue/cli-service if it's present in your project root (next to package.json ). vue.config.js是一个可选配置文件,如果它存在于您的项目根目录中(在package.json旁边),它将由@vue/cli-service自动加载。 You can also use the vue field in package.json , but do note in that case you will be limited to JSON-compatible values only.您也可以使用package.json中的 vue 字段,但请注意,在这种情况下,您将仅限于 JSON 兼容的值。

The file should export an object containing options:该文件应导出包含选项的对象:

 // vue.config.js module.exports = { // options... }

So just create the file by yourself.所以只需自己创建文件。 It is completely optional.它是完全可选的。

It's simple just create file vue.config.js in ROOT folder of project.很简单,只需在项目的 ROOT 文件夹中创建文件vue.config.js

Its very important file.它非常重要的文件。 it's on top of vue project.它位于 vue 项目之上。 People usualy use more than one page in old fasion style.人们通常在旧式风格中使用不止一页。 vue.config.js is right place to define main dependency pages. vue.config.js 是定义主要依赖页面的正确位置。

I used to create main sigle-page app (pwa) but i also need some other pages.我曾经创建主单页应用程序(pwa),但我还需要一些其他页面。 Like error pages or google verify for example.例如错误页面或谷歌验证。

You can change dev server port , sourceMap enable/disable or PWA configuration...您可以更改开发服务器端口、sourceMap 启用/禁用或 PWA 配置...



module.exports = {
  pages: {
    'index': {
      entry: './src/main.ts',
      template: 'public/index.html',
      title: 'Welcome to my vue generator project',
      chunks: ['chunk-vendors', 'chunk-common', 'index']
    },
    'bad': {
      entry: './src/error-instance.ts',
      template: 'public/bad.html',
      title: 'Error page',
      chunks: ['chunk-vendors', 'chunk-common', 'index']
    },
    /* Disabled - Only one time
    'googleVerify': {
      entry: './src/error-instance.ts',
      template: 'public/somelink.html',
      title: 'Error page',
      chunks: ['chunk-vendors', 'chunk-common', 'index']
    },
    */

  },
  devServer: {
    'port': 3000
  },
  css: {
    sourceMap: false
  },
  pwa: {
    name: 'My App',
    themeColor: '#4DBA87',
    msTileColor: '#000000',
    appleMobileWebAppCapable: 'yes',
    appleMobileWebAppStatusBarStyle: 'black',
  },
}

For this config here's main instance file:对于此配置,这里是主实例文件:

import Vue from 'vue'
import App from './App.vue'
import store from './store'

Vue.config.productionTip = false

new Vue({
  store,
  render: h => h(App, {
     props: { error: 'You can not search for assets...' }
  }),
}).$mount('#error')

if you used vue-cli this is in your root like this如果你使用了 vue-cli,这在你的根目录中是这样的

  • your project你的项目
    • node_module节点模块
    • public上市
    • src源代码
    • ... ...
    • vue.config.js vue.config.js

if you dont have it, your project is not vue-cli, it is vit-vue , and your config file name is vit.config.如果你没有它,你的项目不是 vue-cli,它是 vit-vue,你的配置文件名是 vit.config。 vue Vue

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM