Skip to content

Vuetify 3 styles missing in the production build #187

Description

@pferreirafabricio

Hi!
I was having some trouble using this plugin along with Vuetify. For some reason, when I ran npm run build most of the CSS of the components that I was using on my page was not loaded.
After some hours I decided to generate a build without the nuxt-purgecss inside the modules array, and then the styles of the components are showing correctly.

nuxt.config.ts

// https://nuxt.com/docs/api/configuration/nuxt-config
import vuetify from "vite-plugin-vuetify";

export default defineNuxtConfig({
  devtools: { enabled: true },
  build: {
    transpile: ["vue-toastification", "vuetify"],
  },
  modules: [
    "@nuxt/image",
    "@pinia/nuxt",
    "@pinia-plugin-persistedstate/nuxt",
    "@nuxtjs/robots",
    "nuxt-icon",
    // eslint-disable-next-line require-await
    async (_options, nuxt) => {
      nuxt.hooks.hook("vite:extendConfig", (config) =>
        // @ts-ignore
        config.plugins.push(vuetify()),
      );
    },
  ],
  vite: {
    ssr: {
      noExternal: ["vuetify"],
    },
  },
  typescript: {
    shim: false,
  },
  css: [
    "vuetify/lib/styles/main.sass",
    "@mdi/font/css/materialdesignicons.min.css",
  ],
  experimental: {
    inlineSSRStyles: false,
  },
});

package.json:

"devDependencies": {
  "@nuxt/devtools": "latest",
  "@types/node": "^18.16.19",
  "nuxt": "^3.6.2",
  "nuxt-purgecss": "^2.0.0",
  "vite-plugin-vuetify": "^1.0.2",
  "sass": "^1.64.2"
},
"dependencies": {
  "vuetify": "^3.3.11",
  "@mdi/font": "^7.2.96"
}

In dev:

In production build:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions