Skip to content

Commit 52d9829

Browse files
committed
docs: update SASS compiler configuration documentation
1 parent f3be065 commit 52d9829

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

docs/guide/index.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ export interface MOptions {
107107
prefixComposables?: boolean
108108
/**
109109
* Vuetify styles.
110-
*
111-
* If you want to use configFile on SSR, you have to disable `experimental.inlineSSRStyles` in nuxt.config.
112-
*
113-
* @see https://github.com/vuetifyjs/vuetify-loader/tree/master/packages/vite-plugin
114-
* @see https://github.com/vuetifyjs/nuxt-module/issues/78 and https://github.com/vuetifyjs/nuxt-module/issues/74
110+
* Specify `none` to disable Vuetify styles.
115111
*
116112
* @default true
117113
*/
@@ -130,6 +126,7 @@ export interface MOptions {
130126
* @see https://vitejs.dev/config/shared-options.html#css-preprocessormaxworkers
131127
*
132128
* @default false
129+
* @deprecated Vite 7 supports only the modern SASS compiler and API.
133130
*/
134131
disableModernSassCompiler?: boolean
135132
/**

packages/vuetify-nuxt-module/src/types.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,20 @@ export interface MOptions {
249249
configFile: string
250250
}
251251
/**
252-
* The module will add `vuetify/styles` in Nuxt `css` by default.
252+
* Disable the modern SASS compiler and API.
253253
*
254-
* If you want to add custom styles, you should enable this flag to avoid registering `vuetify/styles`.
254+
* The module will check for `sass-embedded` dev dependency:
255+
* - if `disableModernSassCompiler` is enabled, the module will configure the legacy SASS compiler.
256+
* - if `sass-embedded` dependency is installed, the module will configure the modern SASS compiler.
257+
* - otherwise, the module will configure the modern SASS API and will enable [preprocessorMaxWorkers](https://vitejs.dev/config/shared-options.html#css-preprocessormaxworkers), only if not configured from user land.
258+
*
259+
* @https://vitejs.dev/config/shared-options.html#css-preprocessoroptions
260+
* @see https://vitejs.dev/config/shared-options.html#css-preprocessormaxworkers
255261
*
256-
* @see https://github.com/vuetifyjs/nuxt-module/pull/213
257262
* @default false
263+
* @deprecated Vite 7 supports only the modern SASS compiler and API.
258264
*/
259-
disableVuetifyStyles?: boolean
265+
disableModernSassCompiler?: boolean
260266
/**
261267
* Add Vuetify Vite Plugin `transformAssetsUrls`?
262268
*

packages/vuetify-nuxt-module/src/utils/configure-vite.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { Nuxt } from '@nuxt/schema'
22
import type { ObjectImportPluginOptions } from '@vuetify/loader-shared'
33
import type { VuetifyNuxtContext } from './config'
44
import defu from 'defu'
5+
import { isPackageExists } from 'local-pkg'
6+
import semver from 'semver'
57
import { vuetifyConfigurationPlugin } from '../vite/vuetify-configuration-plugin'
68
import { vuetifyDateConfigurationPlugin } from '../vite/vuetify-date-configuration-plugin'
79
import { vuetifyIconsPlugin } from '../vite/vuetify-icons-configuration-plugin'
@@ -16,6 +18,32 @@ export function configureVite (configKey: string, nuxt: Nuxt, ctx: VuetifyNuxtCo
1618
viteInlineConfig.plugins = viteInlineConfig.plugins || []
1719
checkVuetifyPlugins(viteInlineConfig)
1820

21+
if (!ctx.moduleOptions.disableModernSassCompiler) {
22+
// vite version >= 5.4.0 && < 7.0.0
23+
const enableModernSassCompiler = semver.gte(ctx.viteVersion, '5.4.0') && semver.lt(ctx.viteVersion, '7.0.0-0')
24+
if (enableModernSassCompiler) {
25+
const sassEmbedded = isPackageExists('sass-embedded')
26+
if (sassEmbedded) {
27+
viteInlineConfig.css ??= {}
28+
viteInlineConfig.css.preprocessorOptions ??= {}
29+
viteInlineConfig.css.preprocessorOptions.sass ??= {}
30+
viteInlineConfig.css.preprocessorOptions.sass.api = 'modern-compiler'
31+
viteInlineConfig.css.preprocessorOptions.scss ??= {}
32+
viteInlineConfig.css.preprocessorOptions.scss.api = 'modern-compiler'
33+
} else {
34+
viteInlineConfig.css ??= {}
35+
viteInlineConfig.css.preprocessorOptions ??= {}
36+
viteInlineConfig.css.preprocessorOptions.sass ??= {}
37+
viteInlineConfig.css.preprocessorOptions.sass.api = 'modern'
38+
viteInlineConfig.css.preprocessorOptions.scss ??= {}
39+
viteInlineConfig.css.preprocessorOptions.scss.api = 'modern'
40+
if (!('preprocessorMaxWorkers' in viteInlineConfig.css)) {
41+
viteInlineConfig.css.preprocessorMaxWorkers = true
42+
}
43+
}
44+
}
45+
}
46+
1947
viteInlineConfig.optimizeDeps = defu(viteInlineConfig.optimizeDeps, { exclude: ['vuetify'] })
2048

2149
if (ctx.isSSR) {

0 commit comments

Comments
 (0)