vuetify-module icon indicating copy to clipboard operation
vuetify-module copied to clipboard

Using treeShake with nuxt-vite doesn't work

Open ctwhome opened this issue 3 years ago • 3 comments

Vuetify doesn't work when using 'nuxt-vite' and treeShake to be able to modify the sass variables. Without nuxt-vite the app works perfectly image

ctwhome avatar Apr 06 '21 18:04 ctwhome

vite uses rollup this module needs webpack for treeshaking.

Maybe my own module https://github.com/EC-Nordbund/vuetify-module works with vite (uses nuxt components module for treeshaking). I did not test that.

mathe42 avatar Apr 07 '21 18:04 mathe42

How do we force it to use variables.scss then?

J-Sek avatar Aug 18 '21 13:08 J-Sek

vite uses rollup this module needs webpack for treeshaking.

Maybe my own module https://github.com/EC-Nordbund/vuetify-module works with vite (uses nuxt components module for treeshaking). I did not test that.

Can confirm that @mathe42's module works in-place of the vuetify module, for use with vite and treeShake: true. The startup time is significant but vite's hot module reloading works as fast as usual with both components and styles, and with a small delay (8 seconds for me) when changing the variables.

As an addendum to getting it fully working; I had to switch from 'scss' to 'sass' (presumably using the loader that works to merge the variables)

  vite: {
    // ...
    css: {
      preprocessorOptions: {
        sass: {
          additionalData: '\n@import "./assets/styles/variables.scss"\n',
        },
      },
    },
  },

And I had to configure the EC-Nordbund/vuetify-module to load all of the mdi icons, as such:

    iconFont: 'mdi',
    iconInjector: false, // Load full mdi-icon set, see https://github.com/EC-Nordbund/vuetify-module

dsschneidermann avatar Nov 01 '21 12:11 dsschneidermann