简体   繁体   English

babel.config.js 和 vue.config.js 有什么区别,我可以合并这两个文件吗?

[英]what is the difference between babel.config.js and vue.config.js and can i combine the 2 files?

I used the Vue cli to create this application.我使用 Vue cli 创建了这个应用程序。 babel.config.js was already in the directory that the cli automatically created but I added the vue.config.js file. babel.config.js 已经在 cli 自动创建的目录中,但我添加了 vue.config.js 文件。 What is the difference between these 2 files and can i combine them?这两个文件有什么区别,我可以合并它们吗? it is confusing because they both end with "config.js" so i am thinking that they might have something in common.这很令人困惑,因为它们都以“config.js”结尾,所以我认为它们可能有一些共同点。

This is my babel.config.js这是我的 babel.config.js

module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset'
  ]
}

This is my vue.config.js这是我的 vue.config.js

module.exports = {
    devServer: {
        proxy: {
            '^/users': {
                target: 'http://localhost:5000',
                ws: true,
                changeOrigin: true
            },
            '^/api': {
                target: 'http://localhost:5000',
                ws: true,
                changeOrigin: true
            }
        }
    }
};

babel.config.js configures Babel. babel.config.js配置 Babel。 vue.config.js configures Vue. vue.config.js配置 Vue。

These are two different things.这是两个不同的东西。 Babel transforms newer Javascript into old Javascript so that older browsers (notably IE11) can understand it. Babel 将较新的 Javascript 转换为旧的 Javascript,以便较旧的浏览器(尤其是 IE11)可以理解它。 Vue uses Javascript to render DOM nodes. Vue 使用 Javascript 来渲染 DOM 节点。 They work together to make it easy to run a javascript application.它们一起工作,使运行 javascript 应用程序变得容易。

You can configure both packages in package.json, as @skirtle pointed out in the comments, or you can leave them separate so you don't confuse the different configurations.正如@skirtle 在评论中指出的那样,您可以在 package.json 中配置这两个包,或者您可以将它们分开,以免混淆不同的配置。 Same goes for other packages' config files you may encounter in the future like postcss.config.js , eslint.config.js , tailwind.config.js etc.将来可能会遇到的其他包的配置文件也是如此,例如postcss.config.jseslint.config.jstailwind.config.js等。

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

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