Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions playground/css/vite.config-sass-legacy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import path from 'node:path'
import { pathToFileURL } from 'node:url'
import { defineConfig } from 'vite'
import baseConfig from './vite.config.js'

export default defineConfig({
...baseConfig,
css: {
...baseConfig.css,
preprocessorOptions: {
...baseConfig.css.preprocessorOptions,
scss: {
api: 'legacy',
importer: [
function (url) {
return url === 'virtual-dep' ? { contents: '' } : null
},
function (url) {
return url === 'virtual-file-absolute'
? {
contents: `@use "${pathToFileURL(path.join(import.meta.dirname, 'file-absolute.scss')).href}"`,
}
: null
},
function (url) {
return url.endsWith('.wxss') ? { contents: '' } : null
},
],
silenceDeprecations: ['legacy-js-api'],
},
},
},
})
16 changes: 0 additions & 16 deletions playground/css/vite.config-sass-modern-compiler.js

This file was deleted.

34 changes: 3 additions & 31 deletions playground/css/vite.config-sass-modern.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { pathToFileURL } from 'node:url'
import path from 'node:path'
import { defineConfig } from 'vite'
import baseConfig from './vite.config.js'

Expand All @@ -10,36 +8,10 @@ export default defineConfig({
preprocessorOptions: {
...baseConfig.css.preprocessorOptions,
scss: {
.../** @type {import('vite').SassPreprocessorOptions & { api?: undefined }} */ (
baseConfig.css.preprocessorOptions.scss
),
api: 'modern',
additionalData: `$injectedColor: orange;`,
importers: [
{
canonicalize(url) {
return url === 'virtual-dep'
? new URL('custom-importer:virtual-dep')
: null
},
load() {
return {
contents: ``,
syntax: 'scss',
}
},
},
{
canonicalize(url) {
return url === 'virtual-file-absolute'
? new URL('custom-importer:virtual-file-absolute')
: null
},
load() {
return {
contents: `@use "${pathToFileURL(path.join(import.meta.dirname, 'file-absolute.scss')).href}"`,
syntax: 'scss',
}
},
},
],
},
},
},
Expand Down
39 changes: 25 additions & 14 deletions playground/css/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,35 @@ export default defineConfig({
},
preprocessorOptions: {
scss: {
api: 'legacy',
additionalData: `$injectedColor: orange;`,
importer: [
function (url) {
return url === 'virtual-dep' ? { contents: '' } : null
importers: [
{
canonicalize(url) {
return url === 'virtual-dep'
? new URL('custom-importer:virtual-dep')
: null
},
load() {
return {
contents: ``,
syntax: 'scss',
}
},
},
function (url) {
return url === 'virtual-file-absolute'
? {
contents: `@use "${pathToFileURL(path.join(import.meta.dirname, 'file-absolute.scss')).href}"`,
}
: null
},
function (url) {
return url.endsWith('.wxss') ? { contents: '' } : null
{
canonicalize(url) {
return url === 'virtual-file-absolute'
? new URL('custom-importer:virtual-file-absolute')
: null
},
load() {
return {
contents: `@use "${pathToFileURL(path.join(import.meta.dirname, 'file-absolute.scss')).href}"`,
syntax: 'scss',
}
},
},
],
silenceDeprecations: ['legacy-js-api'],
},
styl: {
additionalData: `$injectedColor ?= orange`,
Expand Down