fix(sass): reorder sass importers (#10101)

This commit is contained in:
chenjiajian 2022-09-22 16:42:55 +08:00 committed by GitHub
parent f29fef5dc3
commit a5437319da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 5 deletions

View File

@ -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(

View File

@ -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 */

View File

@ -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`,

View File