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

Prevent Vuetify styles compilation

Open Maxim-Mazurok opened this issue 4 years ago • 4 comments

I want to avoid compiling sass/scss styles when building vuetify app.

I've tried to use solution from here: https://github.com/vuetifyjs/vuetify-loader/issues/201#issuecomment-915892697 Like so:

module.exports = {
  chainWebpack(config) {
    config.module
      .rule("bla-bla")
      .enforce("pre")
      .test(/\.(css|scss|sass)$/)
      .use("null-loader")
      .loader("null-loader")
      .end();
  },
};

But I can still see in the build log that vuetify styles are being compiled:

56 │ $container-padding-x: $grid-gutter / 2 !default;
   │                       ^^^^^^^^^^^^^^^^
   ╵
    node_modules/vuetify/src/styles/settings/_variables.scss 56:23  @import
    node_modules/vuetify/src/styles/settings/_index.sass 1:9        @import
    node_modules/vuetify/src/styles/styles.sass 2:9                 @import
    node_modules/vuetify/src/styles/main.sass 2:9                   root stylesheet

DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.

Even though all resulting CSS files are 0kb:

dist/css/Bla.e7a516a5.css                  0.00 KiB
dist/css/BlaBla.8b5fefc0.css               0.00 KiB
dist/css/BlaBlaBla.8b5fefc0.css            0.00 KiB
dist/css/app.0e433876.css                  0.00 KiB
dist/css/chunk-vendors.a1922ca9.css        0.00 KiB

Maxim-Mazurok avatar Oct 05 '21 05:10 Maxim-Mazurok

Any updates on this? I am also looking for a way to disable the style loading.

apertureless avatar Oct 28 '21 08:10 apertureless

It's already in v2 of the loader, which is only for v3 of vue and vuetify as far as I understand.

Adding this to my vue.config.js:

module.exports = {
  configureWebpack: {
    module: {
      rules: [
        {
          enforce: "pre",
          test: /\.s[ac]ss$/,
          include: /node_modules[/\\]vuetify[/\\]/,
          issuer: /node_modules[/\\]vuetify[/\\]/,
          loader: "null-loader",
        },
      ],
    },
  },
};

helped to make build about 3 times faster. But I still can see vuetify styles building...

Maxim-Mazurok avatar Oct 29 '21 04:10 Maxim-Mazurok

Ah that worked for me.

apertureless avatar Oct 29 '21 07:10 apertureless

Update: This seems to work better (gets rid of build warnings, etc):

// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-var-requires
const Config = require("webpack-chain"); // for auto-complete

module.exports = {
  /** @param { Config } config */
  chainWebpack: (config) => {
    // see https://github.com/vuetifyjs/vuetify-loader/issues/209
    // replace with `styles: 'none'` config in Vuetify v3
    ["sass", "scss"].map((lang) =>
      ["vue", "normal", "vue-modules", "normal-modules"].map((name) => {
        config.module.rule(lang).oneOf(name).use("sass-loader").loader("null-loader");
      })
    );

    // uncomment this to debug webpack config
    // console.log(config.toString()); process.exit();
  },
};

Maxim-Mazurok avatar Nov 02 '21 02:11 Maxim-Mazurok

Hi @apertureless and @Maxim-Mazurok

I implement an similiar solution on my component lib. Vuetify styles are excluded from the build.

But when i use some component from my custom vuetify lib, the vuetify styles are not imported in the main project. Only if use the same component somewhere.

U have some idea how i can solve this ?

ricardo17coelho avatar Mar 29 '23 08:03 ricardo17coelho

No plans to add this to the v2 plugin.

KaelWD avatar Sep 19 '23 07:09 KaelWD