@hidoo/sass-importer
v1.0.0
Published
Custom Sass importer.
Downloads
20
Readme
@hidoo/sass-importer
Custom sass importer.
Installation
npm install @hidoo/sass-importer
Usage
import * as sass from 'sass';
import { createFileImporter } from '@hidoo/sass-importer';
const options = {
importers: [
createFileImporter({
extensions: ['.scss'],
mainFields: ['sass'],
packagePrefix: '^'
})
]
};
const { css } = await sass.compileAsync('path/to/entry.scss', options);
Use with legacy API
import * as sass from 'sass';
import { createImporter } from '@hidoo/sass-importer';
const options = {
file: 'path/to/entry.scss',
importer: [
createImporter({
extensions: ['.scss'],
mainFields: ['sass'],
packagePrefix: '^'
})
]
};
const { css } = await new Promise((resolve, reject) => {
sass.render(options, (error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});
Test
pnpm test
License
MIT