sass-loader
sass-loader copied to clipboard
Add the ability to decorate the default importer
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.