custom properties of themes don't work in vite production build #22866
Replies: 2 comments 1 reply
-
|
This is usually a Vite CSS extraction issue. In dev mode, Vite injects styles via JS (which preserves insertion order), but in production it extracts CSS into files where the ordering can change. A few things to check:
// vite.config.ts
import vuetify from 'vite-plugin-vuetify'
export default defineConfig({
plugins: [
vue(),
vuetify({ autoImport: true }),
],
})
import 'vuetify/styles'
import { createVuetify } from 'vuetify'
Can you share your |
Beta Was this translation helpful? Give feedback.
-
|
Hi @mg1986jp, thanks for the reply. We were able to identify the problem: It was a configuration in the CSP header that prevented runtime bundling. If we set style-src 'self' 'unsafe-inline'; it works. But I don't know if it's a practical solution. Here's my import { fileURLToPath, URL } from 'node:url'
import { defineConfig, type PluginOption } from 'vite'
import vue from '@vitejs/plugin-vue'
import vuetify from 'vite-plugin-vuetify'
import checker from 'vite-plugin-checker'
import { visualizer } from 'rollup-plugin-visualizer'
export default defineConfig({
plugins: [
visualizer({
template: 'sunburst', // or treemap
open: false,
gzipSize: true,
brotliSize: true,
filename: 'bundle-size-analyse.html' // will be saved in project's root
}) as PluginOption,
vue(),
vuetify(),
!process.env.VITEST
? checker({
vueTsc: {
tsconfigPath: 'tsconfig.vitest.json'
},
eslint: {
useFlatConfig: true,
lintCommand: 'eslint "./src/**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}" --no-fix'
}
})
: undefined
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
build: {
minify: 'terser',
assetsInlineLimit: 0,
terserOptions: {
format: {
comments: false
}
},
sourcemap: false
},
server: {
port: 8095
},
base: '/spa/',
define: {
__INTLIFY_JIT_COMPILATION__: true,
__VUE_I18N_LEGACY_API__: false
}
}) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, when I build my app in production mode with vite, the custom properties of the themes (colors etc) don't work. In the devtools of the browser it says they are not set, which isn't true. It doesn't matter if I use a custom theme or a standard theme (e.g. 'light'). When I'm starting the app in dev mode, the layers with the custom properties are working. I'm using vuetify version 4.0.7, vite 8.0.10 and vue 3.5.33
Beta Was this translation helpful? Give feedback.
All reactions