diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index aebb3286584662..70ab1d3d268d8b 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -1441,8 +1441,8 @@ const scss: SassStylePreprocessor = async ( const importer = [internalImporter] if (options.importer) { Array.isArray(options.importer) - ? importer.push(...options.importer) - : importer.push(options.importer) + ? importer.unshift(...options.importer) + : importer.unshift(options.importer) } const { content: data, map: additionalMap } = await getSource( diff --git a/playground/css/sass.scss b/playground/css/sass.scss index 3c7095418e01e6..1db47622b016ad 100644 --- a/playground/css/sass.scss +++ b/playground/css/sass.scss @@ -3,6 +3,7 @@ @import 'css-dep'; // package w/ sass entry points @import 'virtual-dep'; // virtual file added through importer @import '@/pkg-dep'; // package w/out sass field +@import '@/weapp.wxss'; // wxss file .sass { /* injected via vite.config.js */ diff --git a/playground/css/vite.config.js b/playground/css/vite.config.js index d8333b07fb4d63..221c2a75187f35 100644 --- a/playground/css/vite.config.js +++ b/playground/css/vite.config.js @@ -45,9 +45,14 @@ module.exports = { preprocessorOptions: { scss: { additionalData: `$injectedColor: orange;`, - importer(url) { - if (url === 'virtual-dep') return { contents: '' } - } + importer: [ + function (url) { + return url === 'virtual-dep' ? { contents: '' } : null + }, + function (url) { + return url.endsWith('.wxss') ? { contents: '' } : null + } + ] }, styl: { additionalData: `$injectedColor ?= orange`, diff --git a/playground/css/weapp.wxss b/playground/css/weapp.wxss new file mode 100644 index 00000000000000..e69de29bb2d1d6