Skip to content

Commit

Permalink
fix: use modern api by default for vite bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Sep 18, 2024
1 parent 32d3d29 commit 7c2e8e9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
1 change: 1 addition & 0 deletions plugins/development/plugin-palette/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
"@vuepress/helper": "workspace:*",
"chokidar": "^4.0.0"
},
"peerDependencies": {
Expand Down
17 changes: 17 additions & 0 deletions plugins/development/plugin-palette/src/node/palettePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { addViteConfig } from '@vuepress/helper'
import { watch } from 'chokidar'
import type { Plugin } from 'vuepress/core'
import { preparePaletteFile } from './preparePaletteFile.js'
Expand Down Expand Up @@ -56,6 +57,22 @@ export const palettePlugin = ({
'@vuepress/plugin-palette/style': app.dir.temp(tempStyleFile),
}),

extendsBundlerOptions: (bundlerOptions: unknown, app): void => {
// switch to modern api for vite
addViteConfig(bundlerOptions, app, {
css: {
preprocessorOptions: {
sass: {
api: 'modern',
},
scss: {
api: 'modern',
},
},
},
})
},

onPrepared: async (app) => {
await Promise.all([
preparePaletteFile(app, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { addViteConfig } from '@vuepress/helper'
import { watch } from 'chokidar'
import type { PluginFunction } from 'vuepress/core'
import { getDirname, path } from 'vuepress/utils'
Expand Down Expand Up @@ -67,6 +68,19 @@ export const sassPalettePlugin =
},

extendsBundlerOptions: (bundlerOptions: unknown): void => {
// switch to modern api for vite
addViteConfig(bundlerOptions, app, {
css: {
preprocessorOptions: {
sass: {
api: 'modern',
},
scss: {
api: 'modern',
},
},
},
})
injectScssConfigModule(bundlerOptions, app, id)
},

Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions themes/theme-default/src/node/defaultTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,11 @@ export const defaultTheme = ({
// FIXME: hide sass deprecation warning for mixed-decls
addViteConfig(bundlerOptions, app, {
css: {
// switch to modern api
preprocessorOptions: {
sass: {
api: 'modern',
silenceDeprecations: ['mixed-decls'],
},
scss: {
api: 'modern',
silenceDeprecations: ['mixed-decls'],
},
},
Expand Down

0 comments on commit 7c2e8e9

Please sign in to comment.