Bundle a Vue-cli projet without Vuetify

Viewed 222

I try to create some Vue libraries for internal use in our company.

As all of our projects use Vuetify, and our libraries expose some components that use it too, i don't want to bundle Vuetify in the libraries, but use the one installed with the "final" project.

I've look in the Webpack and Vue-cli documentation, and found the externals configuration key in webpack. But this vue.config.js file :

module.exports = {
  configureWebpack: {
    externals: {
      vuetify: "commonjs2 vuetify",
    },
  },
  chainWebpack: config => {
    // These are some necessary steps changing the default webpack config of the Vue CLI
    // that need to be changed in order for Typescript based components to generate their
    // declaration (.d.ts) files.
    //
    // Discussed here https://github.com/vuejs/vue-cli/issues/1081
    if (process.env.NODE_ENV === "production") {
      config.module.rule("ts").uses.delete("cache-loader");

      config.module
        .rule("ts")
        .use("ts-loader")
        .loader("ts-loader")
        .tap(opts => {
          opts.onlyCompileBundledFiles = true;
          opts.transpileOnly = false;
          opts.happyPackMode = false;
          return opts;
        });
    }
  },
  parallel: false,
};

Does'nt seems to works, as Vuetify is still in the bundle (And so, the weight of the output is BIG).

Since I don't want to load Vuetify multiple times... How can i achieve this ?

0 Answers
Related