sass-tilde-importer
v1.0.0
Published
SASS importer that resolves ~ paths to node_modules
Maintainers
Readme
sass-tilde-importer
A custom importer for Sass that maps tilde (~) paths to the current node_modules directory.
Description
This library provides a custom importer function for Sass that allows you to use the tilde (~) prefix in your import statements to reference packages in your node_modules directory. This is particularly useful for maintaining clean and consistent import paths across your Sass/SCSS files.
Features
- Maps
~package-nameimports to the corresponding package in node_modules - Works with both Sass (indented) and SCSS syntaxes
- Supports new API and old API
Installation
npm install sass-tilde-importer
# or
pnpm add sass-tilde-importerUsage
const sass = require('sass');
const tildeImporter = require('sass-tilde-importer');
// Old API
sass.render({
file: 'path/to/your.scss',
importer: [tildeImporter]
}, function(err, result) {
// Handle result
});
// New API
sass.compile('path/to/your.scss', {
importers: [tildeImporter]
}).then(function(result) {
// Handle result
});Example
@import '~bootstrap/scss/bootstrap';
@import '~my-custom-package/styles/main';License
MIT
