Skip to content

Commit b99ad4b

Browse files
authored
Add charset option to js-api (#1732)
1 parent 2299632 commit b99ad4b

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### JS API
44

5+
* Add a `charset` option that controls whether or not Sass emits a
6+
`@charset`/BOM for non-ASCII stylesheets.
57
* Fix Sass npm package types for TS 4.7+ Node16 and NodeNext module resolution.
68

79
## 1.53.0

‎lib/sass.dart‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ Future<CompileResult> compileToResultAsync(String path,
230230
OutputStyle? style,
231231
bool quietDeps = false,
232232
bool verbose = false,
233-
bool sourceMap = false}) =>
233+
bool sourceMap = false,
234+
bool charset = true}) =>
234235
c.compileAsync(path,
235236
logger: logger,
236237
importCache: AsyncImportCache(
@@ -242,7 +243,8 @@ Future<CompileResult> compileToResultAsync(String path,
242243
style: style,
243244
quietDeps: quietDeps,
244245
verbose: verbose,
245-
sourceMap: sourceMap);
246+
sourceMap: sourceMap,
247+
charset: charset);
246248

247249
/// Like [compileStringToResult], except it runs asynchronously.
248250
///

‎lib/src/node/compile.dart‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ NodeCompileResult compile(String path, [CompileOptions? options]) {
4242
quietDeps: options?.quietDeps ?? false,
4343
style: _parseOutputStyle(options?.style),
4444
verbose: options?.verbose ?? false,
45+
charset: options?.charset ?? true,
4546
sourceMap: options?.sourceMap ?? false,
4647
logger: NodeToDartLogger(options?.logger, Logger.stderr(color: color),
4748
ascii: ascii),
@@ -70,6 +71,7 @@ NodeCompileResult compileString(String text, [CompileStringOptions? options]) {
7071
quietDeps: options?.quietDeps ?? false,
7172
style: _parseOutputStyle(options?.style),
7273
verbose: options?.verbose ?? false,
74+
charset: options?.charset ?? true,
7375
sourceMap: options?.sourceMap ?? false,
7476
logger: NodeToDartLogger(options?.logger, Logger.stderr(color: color),
7577
ascii: ascii),
@@ -98,6 +100,7 @@ Promise compileAsync(String path, [CompileOptions? options]) {
98100
quietDeps: options?.quietDeps ?? false,
99101
style: _parseOutputStyle(options?.style),
100102
verbose: options?.verbose ?? false,
103+
charset: options?.charset ?? true,
101104
sourceMap: options?.sourceMap ?? false,
102105
logger: NodeToDartLogger(options?.logger, Logger.stderr(color: color),
103106
ascii: ascii),
@@ -125,6 +128,7 @@ Promise compileStringAsync(String text, [CompileStringOptions? options]) {
125128
quietDeps: options?.quietDeps ?? false,
126129
style: _parseOutputStyle(options?.style),
127130
verbose: options?.verbose ?? false,
131+
charset: options?.charset ?? true,
128132
sourceMap: options?.sourceMap ?? false,
129133
logger: NodeToDartLogger(options?.logger, Logger.stderr(color: color),
130134
ascii: ascii),

‎lib/src/node/compile_options.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class CompileOptions {
1717
external bool? get quietDeps;
1818
external String? get style;
1919
external bool? get verbose;
20+
external bool? get charset;
2021
external bool? get sourceMap;
2122
external bool? get sourceMapIncludeSources;
2223
external NodeLogger? get logger;

0 commit comments

Comments
 (0)