Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/sassc/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def render

Native.option_set_is_indented_syntax_src(native_options, true) if sass?
Native.option_set_input_path(native_options, filename) if filename
Native.option_set_output_path(native_options, output_path) if output_path
Native.option_set_precision(native_options, precision) if precision
Native.option_set_include_path(native_options, load_paths)
Native.option_set_output_style(native_options, output_style_enum)
Expand Down Expand Up @@ -73,6 +74,10 @@ def filename
@options[:filename]
end

def output_path
@options[:output_path]
end

private

def quiet?
Expand Down
51 changes: 51 additions & 0 deletions test/engine_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,57 @@ def test_source_map
MAP
end

def test_source_map_filenames
temp_dir('admin')

temp_file('admin/text-color.scss', <<SCSS)
p {
color: red;
}
SCSS
temp_file('style.scss', <<SCSS)
@import 'admin/text-color';

p {
padding: 20px;
}
SCSS
engine = Engine.new(File.read('style.scss'), {
source_map_file: "output-style.css.map",
filename: "input-style.scss",
output_path: "output-style.css",
source_map_contents: true
})

assert_equal <<CSS.strip, engine.render
p {
color: red; }

p {
padding: 20px; }

/*# sourceMappingURL=output-style.css.map */
CSS


assert_equal <<MAP.strip, engine.source_map
{
\t"version": 3,
\t"file": "output-style.css",
\t"sources": [
\t\t"input-style.scss",
\t\t"admin/text-color.scss"
\t],
\t"sourcesContent": [
\t\t"@import 'admin/text-color';\\n\\np {\\n padding: 20px;\\n}\\n",
\t\t"p {\\n color: red;\\n}\\n"
\t],
\t"names": [],
\t"mappings": "ACAA,AAAA,CAAC,CAAC;EACA,KAAK,EAAE,GAAG,GACX;;ADAD,AAAA,CAAC,CAAC;EACA,OAAO,EAAE,IAAI,GACd"
}
MAP
end

def test_no_source_map
engine = Engine.new("$size: 30px;")
engine.render
Expand Down