Skip to content

Commit dc25ed9

Browse files
committed
CSS: keep source mapping URLs, fixes #692
1 parent a58eb58 commit dc25ed9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

css/css.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,13 @@ func (c *cssMinifier) minifyGrammar() {
250250
c.w.Write(value)
251251
semicolonQueued = true
252252
case css.CommentGrammar:
253-
if len(data) > 5 && data[1] == '*' && data[2] == '!' {
253+
if 5 < len(data) && data[1] == '*' && data[2] == '!' {
254254
c.w.Write(data[:3])
255255
comment := parse.TrimWhitespace(parse.ReplaceMultipleWhitespace(data[3 : len(data)-2]))
256256
c.w.Write(comment)
257257
c.w.Write(data[len(data)-2:])
258+
} else if 5 < len(data) && (data[2] == '#' || data[2] == '@') {
259+
c.w.Write(data) // sourceMappingURL
258260
}
259261
default:
260262
c.w.Write(data)

css/css_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestCSS(t *testing.T) {
1818
}{
1919
{"/*comment*/", ""},
2020
{"/*! bang comment */", "/*!bang comment*/"},
21+
{"/*# sourceMappingURL=url */", "/*# sourceMappingURL=url */"},
2122
{"a;", "a"},
2223
{"i{}/*! bang comment */", "i{}/*!bang comment*/"},
2324
{"i { key: value; key2: value; }", "i{key:value;key2:value}"},

0 commit comments

Comments
 (0)