javascriptvue.jswebpackvue-clicore-js

vue.js: exclude core-js from webpack


Here is my vue.config.js file:

module.exports = {
  configureWebpack: {
    externals: {
      "vue": "Vue",
      "core-js": "core-js",
    },
  },
};

With this config, vue.js (Vue) library is excluded and I can link it from a CDN.

But core-js is packed anyway and not recognized as an external library.

What is wrong with my config?


Solution

  • You need to change babel config.

    Here is my babel.config.js:

    module.exports = {
      presets: [
        [
          "@vue/cli-plugin-babel/preset",
          {
            useBuiltIns: false,
          },
        ],
      ],
    };