Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sass): reorder sass importers #10101

Merged
merged 1 commit into from
Sep 22, 2022
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
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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.