Skip to content

Commit a543731

Browse files
authored
fix(sass): reorder sass importers (#10101)
1 parent f29fef5 commit a543731

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

packages/vite/src/node/plugins/css.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1441,8 +1441,8 @@ const scss: SassStylePreprocessor = async (
14411441
const importer = [internalImporter]
14421442
if (options.importer) {
14431443
Array.isArray(options.importer)
1444-
? importer.push(...options.importer)
1445-
: importer.push(options.importer)
1444+
? importer.unshift(...options.importer)
1445+
: importer.unshift(options.importer)
14461446
}
14471447

14481448
const { content: data, map: additionalMap } = await getSource(

playground/css/sass.scss

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@import 'css-dep'; // package w/ sass entry points
44
@import 'virtual-dep'; // virtual file added through importer
55
@import '@/pkg-dep'; // package w/out sass field
6+
@import '@/weapp.wxss'; // wxss file
67

78
.sass {
89
/* injected via vite.config.js */

playground/css/vite.config.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ module.exports = {
4545
preprocessorOptions: {
4646
scss: {
4747
additionalData: `$injectedColor: orange;`,
48-
importer(url) {
49-
if (url === 'virtual-dep') return { contents: '' }
50-
}
48+
importer: [
49+
function (url) {
50+
return url === 'virtual-dep' ? { contents: '' } : null
51+
},
52+
function (url) {
53+
return url.endsWith('.wxss') ? { contents: '' } : null
54+
}
55+
]
5156
},
5257
styl: {
5358
additionalData: `$injectedColor ?= orange`,

playground/css/weapp.wxss

Whitespace-only changes.

0 commit comments

Comments
 (0)