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: allow passing an array as sass / scss importer #3529

Merged
merged 2 commits into from
May 25, 2021
Merged
Changes from 1 commit
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
7 changes: 1 addition & 6 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -936,12 +936,7 @@ const scss: SassStylePreprocessor = async (
}
})
}
const importer = [internalImporter]
if (options.importer) {
Array.isArray(options.importer)
? importer.concat(options.importer)
: importer.push(options.importer)
}
const importer = [internalImporter].concat(options.importer!)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If options.importer would be undefined here, this would add an undefined value to the array 🤔
Do we really want this non-null assertion here?


Beside that, does this really fix the issue? And if so: why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking on something like this to fix the issue:

  const importer = [internalImporter]
  if (options.importer) {
    if( Array.isArray(options.importer) ) {
      importer.push(...options.importer)
    }
    else {
      importer.push(options.importer)
    }
  }

This could be written in a more compact form but I don't think we will gain in readability.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patak-js So your solution is exactly the same as before but using push instead of concat?


const finalOptions: Sass.Options = {
...options,
Expand Down