Skip to content

Commit e1f00ab

Browse files
authored
docs: add Vuetify styles broken fix when using Nuxt 3.16 to the FAQ page (#301)
* docs: add Vuetify styles broken fix when using Nuxt 3.16 to the FAQ page * chore: include Vuetify version and rename module
1 parent cfc8824 commit e1f00ab

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

docs/guide/faq.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,46 @@ export default defineNuxtConfig({
1313

1414
This PR [fix(nuxt): support serialising rich server logs](https://github.com/nuxt/nuxt/pull/26503) should fix the error in the next Nuxt release (`v3.12.0` or `v4.0.0`).
1515

16+
## Vuetify styles broken with Nuxt 3.16.0
17+
18+
If your Vuetify styles not being applied when using Nuxt 3.16.0, you can drop this module to your modules folder:
19+
20+
```ts
21+
// modules/fix-vuetify-theme-composable.ts
22+
import { addVitePlugin, defineNuxtModule } from '@nuxt/kit'
23+
24+
export default defineNuxtModule({
25+
setup() {
26+
// add vite plugin to patch vuetify theme composable
27+
const detectorRegexp = /\/vuetify\/lib\/composables\/theme\.m?js/
28+
const replaceRegexp = /children: styles.value,\s+id:/
29+
addVitePlugin({
30+
name: 'vuetify-theme-fix',
31+
enforce: 'pre',
32+
transform(code, id) {
33+
if (detectorRegexp.test(id)) {
34+
const match = code.match(replaceRegexp)
35+
if (match?.index) {
36+
return `${code.slice(0, match.index -1)}textContent${code.slice(match.index + 'children'.length)}`
37+
}
38+
}
39+
}
40+
})
41+
}
42+
})
43+
```
44+
45+
or, alternatively, use `unhead` in `legacy` mode; add the following `unhead` configuration to your Nuxt configuration file:
46+
47+
```ts
48+
unhead: {
49+
legacy: true,
50+
renderSSRHeadOptions: {
51+
omitLineBreaks: false
52+
}
53+
}
54+
```
55+
56+
The issue should be fixed once next Vuetify version released (`> v3.7.16`) (fixed in this PR https://github.com/vuetifyjs/vuetify/pull/21106), then:
57+
- add or update the new Vuetify version to your dependencies
58+
- remove the module or `unhead` configuration

0 commit comments

Comments
 (0)