1.0.0 • Published 6 days ago

@hidoo/sass-importer v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 days ago

@hidoo/sass-importer

Test

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