Skip to content

Establish a mechanism that can intervene in the sass / scss importer #3180

@dadajam4

Description

@dadajam4

Clear and concise description of the problem

Currently, vite seems to be overriding the importer option of the css preprocessor option.
I want to make additional settings so that it will not be overwritten, or perform a special import. (For example, json importer)

If you have time to work, we are considering submitting a PR.

Suggested solution

Below is the implementation location for setting the preprocessor option.

const scss: StylePreprocessor = async (source, root, options, resolvers) => {
const render = loadPreprocessor(PreprocessLang.sass, root).render
const finalOptions: Sass.Options = {
...options,
data: await getSource(source, options.filename, options.additionalData),
file: options.filename,
outFile: options.filename,
importer(url, importer, done) {
resolvers.sass(url, importer).then((resolved) => {
if (resolved) {

At this location, you should be able to merge user-configured importers or importers injected by custom plugins as a list.

Alternative

I can't think of an alternative to this request so far.

Additional context

As an option in sass's JavaScript API, the importer is defined to be able to accept multiple list settings.
https://github.com/sass/node-sass#importer--v200---experimental

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions