Skip to content

Commit

Permalink
New: Add tilde importer for sass
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnitto committed Aug 18, 2021
1 parent 9195b4c commit 87f61af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Lib/sass.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import sass from "sass";
import tildeImporter from "node-sass-tilde-importer";
import { styleFiles, compression } from "./helper.mjs";
function render(key) {
const { to, sourcemap } = styleFiles[key];
const result = sass.renderSync({
file: key,
outFile: to[0],
outputStyle: compression ? "compressed" : "expanded",
importer: tildeImporter,
sourceMap: sourcemap,
sourceMapContents: true,
sourceMapEmbed: true,
Expand Down
12 changes: 10 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,17 @@ Thanks to a custom made `resolve` function, you can also use [globbing][glob] in

### Sass

If you want to use [Sass] (`.scss`or `.sass` files) you have to install [`sass`]:
If you want to use [Sass] (`.scss`or `.sass` files) you have to install [`sass`] and [`node-sass-tilde-importer`]:

```bash
yarn add --dev sass
yarn add --dev sass node-sass-tilde-importer
```

You have to ways to import files from `node_modules` (Example with bootstrap):

```css
@import "node_modules/bootstrap/scss/bootstrap";
@import "~bootstrap/scss/bootstrap";
```

### PostCSS
Expand Down Expand Up @@ -497,6 +504,7 @@ not dead
[tailwind file-size]: https://tailwindcss.com/docs/controlling-file-size
[sass]: https://sass-lang.com
[`sass`]: https://www.npmjs.com/package/sass
[`node-sass-tilde-importer`]: https://www.npmjs.com/package/node-sass-tilde-importer
[postcss-import]: https://www.npmjs.com/package/postcss-import
[postcss-focus-visible]: https://www.npmjs.com/package/postcss-focus-visible
[postcss-nested]: https://www.npmjs.com/package/postcss-nested
Expand Down

0 comments on commit 87f61af

Please sign in to comment.