-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error on embedded imports in data urls (#543)
* properly ignore embedded imports in data urls * add a warning * wording * wording * cleaner solution * hard error
- Loading branch information
1 parent
f99379c
commit 6be601c
Showing
4 changed files
with
46 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,27 @@ | ||
"use strict" | ||
// external tooling | ||
const test = require("ava") | ||
const postcss = require("postcss") | ||
|
||
// plugin | ||
const atImport = require("..") | ||
|
||
// internal tooling | ||
const checkFixture = require("./helpers/check-fixture") | ||
|
||
test("should inline data urls", checkFixture, "data-url") | ||
|
||
test("should error on relative urls from stylesheets in data urls", t => { | ||
return postcss() | ||
.use(atImport()) | ||
.process( | ||
"@import url(data:text/css;base64,QGltcG9ydCB1cmwoZm9vLmNzcyk7CgpwIHsKICBjb2xvcjogYmx1ZTsKfQo=);", | ||
{ from: undefined } | ||
) | ||
.catch(error => | ||
t.regex( | ||
error.message, | ||
/Unable to import '(?:.*?)' from a stylesheet that is embedded in a data url/ | ||
) | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
@import url(foo.css);p { color: green; }p { color: blue; }@media (min-width: 320px){@layer foo{ | ||
p { color: green; } } }@media (min-width: 320px){@layer foo{ | ||
p { color: green; } | ||
|
||
p { color: blue; } } }/* Mixed imports: */p { | ||
color: blue; | ||
}p { color: pink; }/* url encoded: */bar { color: green }bar { color: pink } | ||
p { color: blue; } | ||
|
||
@media (min-width: 320px) { | ||
|
||
@layer foo { | ||
p { color: green; } } } | ||
|
||
@media (min-width: 320px) { | ||
|
||
@layer foo { | ||
|
||
p { color: blue; } } } | ||
|
||
/* Mixed imports: */ | ||
|
||
p { color: pink; } | ||
|
||
/* url encoded: */ | ||
|
||
bar { color: green } | ||
|
||
bar { color: pink } |