Skip to content

Commit

Permalink
Clarify that compile and compileString accept optional options (#3373)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goodwine committed Aug 8, 2022
1 parent 72909c9 commit 4728f82
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions js-api-doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,39 @@ much slower,** but they allow custom importers and functions to run
asynchronously.

* [[compile]] and [[compileAsync]] take a path to a Sass file and return the
result of compiling that file to CSS.
result of compiling that file to CSS. These functions accept an additional
[[Options]] argument.

```js
const sass = require('sass');

const result = sass.compile("style.scss");
console.log(result.css);

const compressed = sass.compile("style.scss", {style: "compressed"});
console.log(compressed.css);
```

* [[compileString]] and [[compileStringAsync]] take a string that represents the
contents of a Sass file and return the result of compiling that file to CSS.
These functions accept an additional [[StringOptions]] argument.

```js
const sass = require('sass');

const result = sass.compileString(`
const input = `
h1 {
font-size: 40px;
code {
font-face: Roboto Mono;
}
}`);
}`;

const result = sass.compileString(input);
console.log(result.css);

const compressed = sass.compileString(input, {style: "compressed"});
console.log(compressed.css);
```

## Integrations
Expand Down Expand Up @@ -76,7 +86,7 @@ Sass code by passing in a [[LegacyStringOptions]].
* [[renderSync]] runs synchronously. It's **by far the fastest option** when
using Dart Sass, but at the cost of only supporting synchronous {@link
LegacyImporter | importer} and {@link LegacyFunction | function} plugins.

```js
const sass = require('sass'); // or require('node-sass');

Expand Down

0 comments on commit 4728f82

Please sign in to comment.