admin管理员组

文章数量:1279019

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 bine them? it is confusing because they both end with "config.js" so i am thinking that they might have something in mon.

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
            }
        }
    }
};

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 bine them? it is confusing because they both end with "config.js" so i am thinking that they might have something in mon.

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
            }
        }
    }
};
Share Improve this question asked May 8, 2020 at 7:49 YoIts LemonBoyYoIts LemonBoy 1051 silver badge4 bronze badges 1
  • Both of these files can be merged into package.json if you prefer. See cli.vuejs/config/#vue-config-js and babeljs.io/docs/en/config-files – skirtle Commented May 8, 2020 at 11:02
Add a ment  | 

1 Answer 1

Reset to default 11

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 ments, 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.

本文标签: