Skip to content

Commit

Permalink
fix(sass): reorder sass importers (#10101)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed Sep 22, 2022
1 parent f29fef5 commit a543731
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/css.ts
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions playground/css/sass.scss
Expand Up @@ -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 */
Expand Down
11 changes: 8 additions & 3 deletions playground/css/vite.config.js
Expand Up @@ -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`,
Expand Down
Empty file added playground/css/weapp.wxss
Empty file.

0 comments on commit a543731

Please sign in to comment.