Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. babel.config.js was already in the directory that the cli automatically created but I added the vue.config.js file. 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.

This is my babel.config.js

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

This is my 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
            }
        }
    }
};
like image 490
YoIts LemonBoy Avatar asked May 08 '20 07:05

YoIts LemonBoy


1 Answers

babel.config.js configures Babel. vue.config.js configures Vue.

These are two different things. Babel transforms newer Javascript into old Javascript so that older browsers (notably IE11) can understand it. Vue uses Javascript to render DOM nodes. They work together to make it easy to run a javascript application.

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. Same goes for other packages' config files you may encounter in the future like postcss.config.js, eslint.config.js, tailwind.config.js etc.

like image 115
Excalibaard Avatar answered Oct 13 '22 00:10

Excalibaard