Node Sass Tilde Importer

1.0.2 · abandoned · verified Sun Apr 19

node-sass-tilde-importer is a custom importer for node-sass that enabled the resolution of Sass `@import` statements beginning with a tilde (~) to absolute paths within the nearest `node_modules` directory. This functionality was essential for integrating npm-installed Sass libraries (e.g., Bootstrap's SCSS files) into projects built with `node-sass` and bundlers like Webpack (via `sass-loader`). The package's current stable version is 1.0.2, last published in March 2018. It has no discernible release cadence, indicating it is no longer actively maintained. Its primary differentiator was providing `~` path resolution for `node-sass`, a feature now largely superseded or natively handled by modern Sass compilers (Dart Sass, available as the `sass` npm package) and contemporary bundler loaders (e.g., `sass-loader` v8+). Given the end-of-life status and deprecation of `node-sass` itself, this package is considered obsolete for new projects and for migrations to modern Sass environments.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to use node-sass-tilde-importer with the deprecated `node-sass` compiler to resolve tilde imports.

const sass = require('node-sass');
const tildeImporter = require('node-sass-tilde-importer');

const scssContent = `
  // Example of importing a node_module like Bootstrap
  @import "~bootstrap/scss/functions";
  @import "~bootstrap/scss/variables";
  @import "~bootstrap/scss/mixins";
  
  .my-component {
    color: $blue;
    padding: map-get($spacers, 3);
  }
`;

sass.render({
  data: scssContent,
  importer: tildeImporter,
  outputStyle: 'expanded'
}, function(error, result) {
  if (error) {
    console.error(`Sass compilation error: ${error.message} on line ${error.line} in ${error.file}`);
  } else {
    console.log('Compiled CSS:\n', result.css.toString());
  }
});

view raw JSON →