Add the ability to decorate the default importer
sgarfinkel opened this issue · 1 comments
Feature Proposal
I would like the ability to decorate the default importer. My primary use-case here is to dedupe global imports with a cache. I could leverage something like https://github.com/maoberlehner/node-sass-magic-importer which does this already, but then I'd lose the ability to resolve URLs with Webpack (including goodies such as aliases). Instead it would be handy to add some new functionality to decorate the default importer like this:
const importerDecorator = (importer) => {
const resolved = new Set();
return (url, prev, done) => {
return importer(url, prev, ({ file }) => {
done(resolved.has(file) ? { file: '' } : { file });
resolved.add(file);
});
};
};
Feature Use Case
See above for a use-case.
Please paste the results of npx webpack-cli info
here, and mention other relevant information
You can recreate own importer using https://github.com/webpack-contrib/sass-loader/blob/master/src/utils.js#L653 at your own risk (somewhere here issue about it and it was export for this purposes, also don't forget to disable webpack), our importer is not public and can change its logic from version to version (even in patch vesions), we don't want officially to provide this ability and maintance it, sorry