node-sass-glob-importer
Version:
Custom importer for node-sass which makes it possible to use glob syntax in Sass import statements
27 lines (21 loc) • 570 B
text/typescript
import {
buildIncludePaths,
resolveGlobUrl,
} from 'node-sass-magic-importer/dist/toolbox';
export = function globImporter() {
return function importer(url: string, prev: string) {
const nodeSassOptions = this.options;
const includePaths = buildIncludePaths(
nodeSassOptions.includePaths,
prev,
);
const filePaths = resolveGlobUrl(url, includePaths);
if (filePaths) {
const contents = filePaths
.map((x: string) => `@import '${x}';`)
.join(`\n`);
return { contents };
}
return null;
};
};