Skip to content

Commit

Permalink
Expose the option to embed sources in the source map.
Browse files Browse the repository at this point in the history
  • Loading branch information
msiedlarek authored and bep committed Dec 1, 2022
1 parent 8d990b3 commit b86ad77
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ type Args struct {
// If enabled, a sourcemap will be generated and returned in Result.
EnableSourceMap bool

// If enabled, sources will be embedded in the generated source map.
SourceMapIncludeSources bool

// Custom resolver to use to resolve imports.
// If set, this will be the first in the resolver chain.
ImportResolver ImportResolver
Expand Down
3 changes: 2 additions & 1 deletion transpiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ func (t *Transpiler) Execute(args Args) (Result, error) {
Url: args.URL,
},
},
SourceMap: args.EnableSourceMap,
SourceMap: args.EnableSourceMap,
SourceMapIncludeSources: args.SourceMapIncludeSources,
},
}

Expand Down
1 change: 1 addition & 0 deletions transpiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func TestTranspilerVariants(t *testing.T) {
}{
{"Output style compressed", Options{}, Args{Source: "div { color: #ccc; }", OutputStyle: OutputStyleCompressed}, Result{CSS: "div{color:#ccc}"}},
{"Enable Source Map", Options{}, Args{Source: "div{color:blue;}", URL: "file://myproject/main.scss", OutputStyle: OutputStyleCompressed, EnableSourceMap: true}, Result{CSS: "div{color:blue}", SourceMap: "{\"version\":3,\"sourceRoot\":\"\",\"sources\":[\"file://myproject/main.scss\"],\"names\":[],\"mappings\":\"AAAA\"}"}},
{"Enable Source Map with sources", Options{}, Args{Source: "div{color:blue;}", URL: "file://myproject/main.scss", OutputStyle: OutputStyleCompressed, EnableSourceMap: true, SourceMapIncludeSources: true}, Result{CSS: "div{color:blue}", SourceMap: "{\"version\":3,\"sourceRoot\":\"\",\"sources\":[\"file://myproject/main.scss\"],\"names\":[],\"mappings\":\"AAAA\",\"sourcesContent\":[\"div{color:blue;}\"]}"}},
{"Sass syntax", Options{}, Args{
Source: `$font-stack: Helvetica, sans-serif
$primary-color: #333
Expand Down

0 comments on commit b86ad77

Please sign in to comment.