Skip to content

Commit

Permalink
docs: add api option documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalexiei committed Nov 1, 2024
1 parent 9218617 commit 43a3241
Showing 1 changed file with 46 additions and 6 deletions.
52 changes: 46 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
};
```

#### rollup.config.ts
### rollup.config.ts

Add `allowSyntheticDefaultImports`, or `esModuleInterop` (enables `allowSyntheticDefaultImports`), to tsconfig.json:

Expand Down Expand Up @@ -51,11 +51,12 @@ Profit.

### `output`

- Type: `Boolean|String|Function` _(default: false)_
- Type: `Boolean|String|Function`
- Default: `false`

```js
sass({
// Default behaviour disable output
// Default behavior disable output
output: false,

// Write all styles to the bundle destination where .js is replaced by .css
Expand All @@ -64,7 +65,7 @@ sass({
// Filename to write all styles
output: 'bundle.css',

// Callback that will be called ongenerate with two arguments:
// Callback that will be called on generate bundle with two arguments:
// - styles: the concatenated styles in order of imported
// - styleNodes: an array of style objects:
// [
Expand All @@ -79,7 +80,8 @@ sass({

### `insert`

- Type: `Boolean` _(default: false)_
- Type: `Boolean`
- Default: `false`

If you specify `true`, the plugin will insert compiled CSS into `<head/>` tag, via utility function that it will output
in your build bundle.
Expand Down Expand Up @@ -164,14 +166,36 @@ the exported vars.

### `runtime`

- Type: `Object` _(default: sass)_
- Type: `Object`
- Default: `sass`

If you specify an object, it will be used instead of [sass](https://github.com/sass/dart-sass). You can use this to pass a different sass compiler (for example the `node-sass` npm package).

### `api`

- Type: `'legacy'|'modern'`
- Default: `'legacy'`

```js
sass(); // default to legacy

sass({ api: 'modern' });

sass({
api: 'modern',
options: {
style: 'compressed',
},
});
```

### `options`

- Type: `Object`

> [!NOTE]
> The content of `options` is sensible to the value specified in `api` option
Options for [sass](https://github.com/sass/dart-sass) or your own runtime sass compiler.

If you specify `data`, the plugin will treat as prepend sass string.
Expand All @@ -185,6 +209,22 @@ sass({
});
```

---

> [!TIP]
> If your are working with npm packages packages, consider to use
> [NodePackageImporter](https://sass-lang.com/documentation/js-api/classes/nodepackageimporter/)
>
> ```js
> import * as sass from 'sass';
>
> sass({
> options: {
> importers: [new sass.NodePackageImporter()],
> },
> });
> ```
### `include`
- Type: `string | string[]`
Expand Down

0 comments on commit 43a3241

Please sign in to comment.