",
]
`;
exports[`loader should register dependencies using the "messages" API: errors 1`] = `[]`;
exports[`loader should register dependencies using the "messages" API: warnings 1`] = `[]`;
exports[`loader should reuse PostCSS AST: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`loader should reuse PostCSS AST: errors 1`] = `[]`;
exports[`loader should reuse PostCSS AST: warnings 1`] = `[]`;
exports[`loader should throw an error on invalid syntax: errors 1`] = `
[
"ModuleBuildError: Module build failed (from \`replaced original path\`):
SyntaxError
(1:3) /test/fixtures/css/style.css Unnecessary curly bracket
> 1 | a {
| ^
2 | color: black;
3 | }
",
]
`;
exports[`loader should throw an error on invalid syntax: warnings 1`] = `[]`;
exports[`loader should work with SugarSS: css 1`] = `
"a {
color: black
}
"
`;
exports[`loader should work with SugarSS: errors 1`] = `[]`;
exports[`loader should work with SugarSS: warnings 1`] = `[]`;
exports[`loader should work: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`loader should work: errors 1`] = `[]`;
exports[`loader should work: warnings 1`] = `[]`;
postcss-loader-7.0.2/test/__snapshots__/postcssOptions.test.js.snap 0000664 0000000 0000000 00000103625 14341464453 0025624 0 ustar 00root root 0000000 0000000 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`"postcssOptions" option should throw an error with "syntax" option on the unresolved syntax: errors 1`] = `
[
"ModuleBuildError: Module build failed (from \`replaced original path\`):
TypeError: Cannot read properties of undefined (reading 'parse')",
"ModuleError: Module Error (from \`replaced original path\`):
Loading PostCSS "unresolved" syntax failed: Cannot find module 'unresolved' from 'src/utils.js'",
]
`;
exports[`"postcssOptions" option should throw an error with "syntax" option on the unresolved syntax: warnings 1`] = `[]`;
exports[`"postcssOptions" option should throw an error with the "config" option on the invalid config: errors 1`] = `
[
"ModuleBuildError: Module build failed (from \`replaced original path\`):
Error: invalid postcss config",
]
`;
exports[`"postcssOptions" option should throw an error with the "config" option on the invalid config: warnings 1`] = `[]`;
exports[`"postcssOptions" option should throw an error with the "config" option on the unresolved config: errors 1`] = `
[
"ModuleBuildError: Module build failed (from \`replaced original path\`):
Error: No PostCSS config found in: /test/fixtures/config-scope/css/unresolve.js",
]
`;
exports[`"postcssOptions" option should throw an error with the "config" option on the unresolved config: warnings 1`] = `[]`;
exports[`"postcssOptions" option should throw an error with the "parser" option on the unresolved parser: errors 1`] = `
[
"ModuleBuildError: Module build failed (from \`replaced original path\`):
TypeError: parser is not a function",
"ModuleError: Module Error (from \`replaced original path\`):
Loading PostCSS "unresolved" parser failed: Cannot find module 'unresolved' from 'src/utils.js'",
]
`;
exports[`"postcssOptions" option should throw an error with the "parser" option on the unresolved parser: warnings 1`] = `[]`;
exports[`"postcssOptions" option should throw an error with the "plugins" option on the unresolved plugin: errors 1`] = `
[
"ModuleError: Module Error (from \`replaced original path\`):
Loading PostCSS "postcss-unresolved" plugin failed: Cannot find module 'postcss-unresolved' from 'src/utils.js'",
]
`;
exports[`"postcssOptions" option should throw an error with the "plugins" option on the unresolved plugin: warnings 1`] = `[]`;
exports[`"postcssOptions" option should throw an error with the "stringifier" option on the unresolved stringifier: errors 1`] = `
[
"ModuleBuildError: Module build failed (from \`replaced original path\`):
TypeError: this.stringify is not a function",
"ModuleError: Module Error (from \`replaced original path\`):
Loading PostCSS "unresolved" stringifier failed: Cannot find module 'unresolved' from 'src/utils.js'",
]
`;
exports[`"postcssOptions" option should throw an error with the "stringifier" option on the unresolved stringifier: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work "Function" value and with "Array" syntax of the "plugins" option: css 1`] = `
"a {
color: rgba(0, 0, 0, 1.0);
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work "Function" value and with "Array" syntax of the "plugins" option: errors 1`] = `[]`;
exports[`"postcssOptions" option should work "Function" value and with "Array" syntax of the "plugins" option: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work "Function" value and with "Object" syntax of the "plugins" option: css 1`] = `
"a {
color: rgba(0, 0, 0, 1.0);
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work "Function" value and with "Object" syntax of the "plugins" option: errors 1`] = `[]`;
exports[`"postcssOptions" option should work "Function" value and with "Object" syntax of the "plugins" option: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work "Function" value: css 1`] = `
"a {
color: rgba(0, 0, 0, 1.0);
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work "Function" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work "Function" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work and provide API for the configuration: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
border-top-color: blue;
border-right-color: blue;
border-left-color: blue;
background-color: #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work and provide API for the configuration: errors 1`] = `[]`;
exports[`"postcssOptions" option should work and provide API for the configuration: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with "from", "to" and "map" options (absolute paths): css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with "from", "to" and "map" options (absolute paths): errors 1`] = `[]`;
exports[`"postcssOptions" option should work with "from", "to" and "map" options (absolute paths): map 1`] = `undefined`;
exports[`"postcssOptions" option should work with "from", "to" and "map" options (absolute paths): warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with "from", "to" and "map" options (relative paths): css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with "from", "to" and "map" options (relative paths): errors 1`] = `[]`;
exports[`"postcssOptions" option should work with "from", "to" and "map" options (relative paths): map 1`] = `undefined`;
exports[`"postcssOptions" option should work with "from", "to" and "map" options (relative paths): warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options "String" value (relative path): css 1`] = `
"a { color: rgba(0, 0, 0, 1.0) }
.foo {
float: right;
}
"
`;
exports[`"postcssOptions" option should work with the "config" options "String" value (relative path): errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options "String" value (relative path): warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options and resolve "from" and "to" options: css 1`] = `
"a { color: black }
.foo {
float: right;
}
"
`;
exports[`"postcssOptions" option should work with the "config" options and resolve "from" and "to" options: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options and resolve "from" and "to" options: source map 1`] = `
{
"file": "style.css",
"mappings": "AAAA,IAAI,aAAa;;AAEjB;EACE,YAAY;AACd",
"names": [],
"sourceRoot": "",
"sources": [
"style.css",
],
"sourcesContent": [
"a { color: black }
.foo {
float: right;
}
",
],
"version": 3,
}
`;
exports[`"postcssOptions" option should work with the "config" options and resolve "from" and "to" options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options and use plugins: css 1`] = `
"a { color: black }
.foo {
float: right;
}
.bar {
border-top-color: blue;
border-right-color: blue;
border-left-color: blue;
background-color: #fafafa;
}
@media (prefers-color-scheme: dark) {
:root:not(.is-light) { /* :root is for HTML documents */
--text-color: white
}
html:not(.is-light) body {
background: black
}
}
:root.is-dark { /* :root is for HTML documents */
--text-color: white
}
html.is-dark body {
background: black
}"
`;
exports[`"postcssOptions" option should work with the "config" options and use plugins: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options and use plugins: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "String" value (absolute path): css 1`] = `
"a { color: rgba(0, 0, 0, 1.0) }
.foo {
float: right;
}
"
`;
exports[`"postcssOptions" option should work with the "config" options with "String" value (absolute path): errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "String" value (absolute path): warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "String" value (with path to the directory with the configuration): css 1`] = `
"a { color: rgba(0, 0, 0, 1.0) }
.foo {
float: right;
}
"
`;
exports[`"postcssOptions" option should work with the "config" options with "String" value (with path to the directory with the configuration): errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "String" value (with path to the directory with the configuration): warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "String" value and respect all options: css 1`] = `
"a {
color: black
}
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLnNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtFQUNFO0FBREYiLCJmaWxlIjoic3R5bGUuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiYVxuICBjb2xvcjogYmxhY2tcbiJdfQ== */"
`;
exports[`"postcssOptions" option should work with the "config" options with "String" value and respect all options: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "String" value and respect all options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "false" value: css 1`] = `
"a { color: black }
.foo {
float: right;
}
"
`;
exports[`"postcssOptions" option should work with the "config" options with "false" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "false" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "package.json" configuration: css 1`] = `
".import {
color: red;
}
.test {
color: blue;
}
"
`;
exports[`"postcssOptions" option should work with the "config" options with "package.json" configuration: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "package.json" configuration: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "true" value: css 1`] = `
"a { color: rgba(0, 0, 0, 1.0) }
.foo {
float: right;
}
"
`;
exports[`"postcssOptions" option should work with the "config" options with "true" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "true" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "map" option and generate inlined source maps: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsImZpbGUiOiJzdHlsZS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyJhIHtcbiAgY29sb3I6IGJsYWNrO1xufVxuXG5hIHtcbiAgY29sb3I6IHJlZDtcbn1cblxuYSB7XG4gIGNvbG9yOiBncmVlbjtcbn1cblxuYSB7XG4gIGNvbG9yOiBibHVlO1xufVxuXG4uY2xhc3Mge1xuICAteC1ib3JkZXItY29sb3I6IGJsdWUgYmx1ZSAqO1xuICAteC1jb2xvcjogKiAjZmFmYWZhO1xufVxuXG4uY2xhc3MtZm9vIHtcbiAgLXotYm9yZGVyLWNvbG9yOiBibHVlIGJsdWUgKjtcbiAgLXotY29sb3I6ICogI2ZhZmFmYTtcbn1cblxuLnBob25lIHtcbiAgJl90aXRsZSB7XG4gICAgd2lkdGg6IDUwMHB4O1xuXG4gICAgQG1lZGlhIChtYXgtd2lkdGg6IDUwMHB4KSB7XG4gICAgICB3aWR0aDogYXV0bztcbiAgICB9XG5cbiAgICBib2R5LmlzX2RhcmsgJiB7XG4gICAgICBjb2xvcjogd2hpdGU7XG4gICAgfVxuICB9XG5cbiAgaW1nIHtcbiAgICBkaXNwbGF5OiBibG9jaztcbiAgfVxufVxuIl19 */"
`;
exports[`"postcssOptions" option should work with the "map" option and generate inlined source maps: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "map" option and generate inlined source maps: map 1`] = `undefined`;
exports[`"postcssOptions" option should work with the "map" option and generate inlined source maps: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "parser" option with "Function" value: css 1`] = `
"a {
color: black
}
"
`;
exports[`"postcssOptions" option should work with the "parser" option with "Function" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "parser" option with "Function" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "parser" option with "Object" value: css 1`] = `
"a {
color: black
}
"
`;
exports[`"postcssOptions" option should work with the "parser" option with "Object" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "parser" option with "Object" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "parser" option with "String" value: css 1`] = `
"a {
color: black
}
"
`;
exports[`"postcssOptions" option should work with the "parser" option with "String" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "parser" option with "String" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and not throw an error on falsy plugin: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and not throw an error on falsy plugin: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and override the previous plugin options: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
border-top-color: blue;
border-right-color: blue;
border-left-color: blue;
background-color: #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and override the previous plugin options: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and override the previous plugin options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and support disabling plugins from the configuration: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and support disabling plugins from the configuration: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and support disabling plugins from the configuration: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value, and config, and override the previous plugin options: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
border-top-color: blue;
border-right-color: blue;
border-left-color: blue;
background-color: #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value, and config, and override the previous plugin options: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value, and config, and override the previous plugin options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value: css 1`] = `
"a {
color: rgba(0, 0, 0, 1.0);
}
a {
color: rgba(255, 0, 0, 1.0);
}
a {
color: rgba(0, 255, 0, 1.0);
}
a {
color: rgba(0, 0, 255, 1.0);
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
border-top-color: rgba(0, 0, 255, 1.0);
border-right-color: rgba(0, 0, 255, 1.0);
border-left-color: rgba(0, 0, 255, 1.0);
background-color: #fafafa;
}
.phone_title {
width: 100px;
}
@media (max-width: 500px) {
.phone_title {
width: 100px
}
}
body.is_dark .phone_title {
color: rgba(0, 0, 0, 0);
}
.phone img {
display: block;
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and only disabled plugins: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and only disabled plugins: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and only disabled plugins: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and override the previous plugin options: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
border-top-color: blue;
border-right-color: blue;
border-left-color: blue;
background-color: #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and override the previous plugin options: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and override the previous plugin options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and support disabling plugins from the configuration: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and support disabling plugins from the configuration: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and support disabling plugins from the configuration: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value, and config, and override the previous plugin options: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
border-top-color: blue;
border-right-color: blue;
border-left-color: blue;
background-color: #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value, and config, and override the previous plugin options: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value, and config, and override the previous plugin options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: rgba(0, 0, 255, 1.0);
}
.class {
border-top-color: rgba(0, 0, 255, 1.0);
border-right-color: rgba(0, 0, 255, 1.0);
border-left-color: rgba(0, 0, 255, 1.0);
background-color: #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone_title {
width: 500px;
}
@media (max-width: 500px) {
.phone_title {
width: auto
}
}
body.is_dark .phone_title {
color: white;
}
.phone img {
display: block;
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with empty "Array" value: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with empty "Array" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with empty "Array" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with empty "Object" value: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with empty "Object" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with empty "Object" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with the "default" property with options: css 1`] = `
"a {
color: black;
}
a {
color: rgba(0, 0, 255, 0.5);
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with the "default" property with options: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with the "default" property with options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with the "default" property without options: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: rgba(0, 0, 255, 1.0);
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"postcssOptions" option should work with the "plugins" option with the "default" property without options: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with the "default" property without options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "stringifier" option with "Function" value: css 1`] = `
"a {
color : black ;
}
a {
color : red ;
}
a {
color : green ;
}
a {
color : blue ;
}
.class {
-x-border-color : blue blue * ;
-x-color : * #fafafa ;
}
.class-foo {
-z-border-color : blue blue * ;
-z-color : * #fafafa ;
}
.phone {
_title {
width : 500px ;
@media ( max-width : 500px ) {
width : auto ;
}
body .is_dark {
color : white ;
}
}
img {
display : block ;
}
}
"
`;
exports[`"postcssOptions" option should work with the "stringifier" option with "Function" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "stringifier" option with "Function" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "stringifier" option with "Object" value: css 1`] = `
"a
color: black
a
color: red
a
color: green
a
color: blue
.class
-x-border-color: blue blue *
-x-color: * #fafafa
.class-foo
-z-border-color: blue blue *
-z-color: * #fafafa
.phone
&_title
width: 500px
@media (max-width: 500px)
width: auto
body.is_dark &
color: white
img
display: block
"
`;
exports[`"postcssOptions" option should work with the "stringifier" option with "Object" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "stringifier" option with "Object" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "stringifier" option with "String" value: css 1`] = `
"a
color: black
a
color: red
a
color: green
a
color: blue
.class
-x-border-color: blue blue *
-x-color: * #fafafa
.class-foo
-z-border-color: blue blue *
-z-color: * #fafafa
.phone
&_title
width: 500px
@media (max-width: 500px)
width: auto
body.is_dark &
color: white
img
display: block
"
`;
exports[`"postcssOptions" option should work with the "stringifier" option with "String" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "stringifier" option with "String" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "syntax" option with "Object" value: css 1`] = `
"a
color: black
"
`;
exports[`"postcssOptions" option should work with the "syntax" option with "Object" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "syntax" option with "Object" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "syntax" option with "String" value: css 1`] = `
"a
color: black
"
`;
exports[`"postcssOptions" option should work with the "syntax" option with "String" value: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "syntax" option with "String" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work without the specified values in the "postcssOptions" option: css 1`] = `
"a { color: rgba(0, 0, 0, 1.0) }
.foo {
float: right;
}
"
`;
exports[`"postcssOptions" option should work without the specified values in the "postcssOptions" option: errors 1`] = `[]`;
exports[`"postcssOptions" option should work without the specified values in the "postcssOptions" option: warnings 1`] = `[]`;
postcss-loader-7.0.2/test/__snapshots__/sourceMap.test.js.snap 0000664 0000000 0000000 00000035576 14341464453 0024521 0 ustar 00root root 0000000 0000000 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`"sourceMap" option should generate inline source maps when the "devtool" is "false": css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsImZpbGUiOiJzdHlsZS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyJhIHtcbiAgY29sb3I6IGJsYWNrO1xufVxuXG5hIHtcbiAgY29sb3I6IHJlZDtcbn1cblxuYSB7XG4gIGNvbG9yOiBncmVlbjtcbn1cblxuYSB7XG4gIGNvbG9yOiBibHVlO1xufVxuXG4uY2xhc3Mge1xuICAteC1ib3JkZXItY29sb3I6IGJsdWUgYmx1ZSAqO1xuICAteC1jb2xvcjogKiAjZmFmYWZhO1xufVxuXG4uY2xhc3MtZm9vIHtcbiAgLXotYm9yZGVyLWNvbG9yOiBibHVlIGJsdWUgKjtcbiAgLXotY29sb3I6ICogI2ZhZmFmYTtcbn1cblxuLnBob25lIHtcbiAgJl90aXRsZSB7XG4gICAgd2lkdGg6IDUwMHB4O1xuXG4gICAgQG1lZGlhIChtYXgtd2lkdGg6IDUwMHB4KSB7XG4gICAgICB3aWR0aDogYXV0bztcbiAgICB9XG5cbiAgICBib2R5LmlzX2RhcmsgJiB7XG4gICAgICBjb2xvcjogd2hpdGU7XG4gICAgfVxuICB9XG5cbiAgaW1nIHtcbiAgICBkaXNwbGF5OiBibG9jaztcbiAgfVxufVxuIl19 */"
`;
exports[`"sourceMap" option should generate inline source maps when the "devtool" is "false": errors 1`] = `[]`;
exports[`"sourceMap" option should generate inline source maps when the "devtool" is "false": warnings 1`] = `[]`;
exports[`"sourceMap" option should generate inline source maps when the "devtool" is "true": css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsImZpbGUiOiJzdHlsZS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyJhIHtcbiAgY29sb3I6IGJsYWNrO1xufVxuXG5hIHtcbiAgY29sb3I6IHJlZDtcbn1cblxuYSB7XG4gIGNvbG9yOiBncmVlbjtcbn1cblxuYSB7XG4gIGNvbG9yOiBibHVlO1xufVxuXG4uY2xhc3Mge1xuICAteC1ib3JkZXItY29sb3I6IGJsdWUgYmx1ZSAqO1xuICAteC1jb2xvcjogKiAjZmFmYWZhO1xufVxuXG4uY2xhc3MtZm9vIHtcbiAgLXotYm9yZGVyLWNvbG9yOiBibHVlIGJsdWUgKjtcbiAgLXotY29sb3I6ICogI2ZhZmFmYTtcbn1cblxuLnBob25lIHtcbiAgJl90aXRsZSB7XG4gICAgd2lkdGg6IDUwMHB4O1xuXG4gICAgQG1lZGlhIChtYXgtd2lkdGg6IDUwMHB4KSB7XG4gICAgICB3aWR0aDogYXV0bztcbiAgICB9XG5cbiAgICBib2R5LmlzX2RhcmsgJiB7XG4gICAgICBjb2xvcjogd2hpdGU7XG4gICAgfVxuICB9XG5cbiAgaW1nIHtcbiAgICBkaXNwbGF5OiBibG9jaztcbiAgfVxufVxuIl19 */"
`;
exports[`"sourceMap" option should generate inline source maps when the "devtool" is "true": errors 1`] = `[]`;
exports[`"sourceMap" option should generate inline source maps when the "devtool" is "true": warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with "true" value and previous loader returns source maps ("sass-loader"): css 1`] = `
"a {
color: coral;
}
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLnNjc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7RUFBSSIsImZpbGUiOiJzdHlsZS5zY3NzIiwic291cmNlc0NvbnRlbnQiOlsiYSB7XG4gIGNvbG9yOiBjb3JhbDtcbn0iXX0= */"
`;
exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with "true" value and previous loader returns source maps ("sass-loader"): errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with "true" value and previous loader returns source maps ("sass-loader"): warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with values and previous loader returns source maps ("sass-loader"): css 1`] = `
"a {
color: coral;
}
/*# sourceMappingURL=style.scss.map */"
`;
exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with values and previous loader returns source maps ("sass-loader"): errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with values and previous loader returns source maps ("sass-loader"): source map 1`] = `
{
"file": "style.scss",
"mappings": "AAAA;EAAI",
"names": [],
"sourceRoot": "",
"sources": [
"style.scss",
],
"sourcesContent": [
"a {
color: coral;
}",
],
"version": 3,
}
`;
exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with values and previous loader returns source maps ("sass-loader"): warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("less-loader"): css 1`] = `
"a {
color: coral;
}
"
`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("less-loader"): errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("less-loader"): source map 1`] = `
{
"mappings": "AAAA;EAAI,YAAA",
"names": [],
"sourceRoot": "",
"sources": [
"less/style.less",
],
"sourcesContent": [
"a {
color: coral;
}
",
],
"version": 3,
}
`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("less-loader"): warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("sass-loader"): css 1`] = `
"a {
color: coral;
}"
`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("sass-loader"): errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("sass-loader"): source map 1`] = `
{
"mappings": "AAAA;EAAI",
"names": [],
"sourceRoot": "",
"sources": [
"scss/style.scss",
],
"sourcesContent": [
"a {
color: coral;
}",
],
"version": 3,
}
`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("sass-loader"): warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps when value is not specified and the "devtool" with "source-map" value: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"sourceMap" option should generate source maps when value is not specified and the "devtool" with "source-map" value: errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps when value is not specified and the "devtool" with "source-map" value: source map 1`] = `
{
"mappings": "AAAA",
"names": [],
"sourceRoot": "",
"sources": [
"css/style.css",
],
"sourcesContent": [
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
",
],
"version": 3,
}
`;
exports[`"sourceMap" option should generate source maps when value is not specified and the "devtool" with "source-map" value: warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps with "false" value, but the "postcssOptions.map" has values: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"sourceMap" option should generate source maps with "false" value, but the "postcssOptions.map" has values: errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps with "false" value, but the "postcssOptions.map" has values: source map 1`] = `
{
"file": "style.css",
"mappings": "AAAA",
"names": [],
"sourceRoot": "",
"sources": [
"style.css",
],
"sourcesContent": [
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
",
],
"version": 3,
}
`;
exports[`"sourceMap" option should generate source maps with "false" value, but the "postcssOptions.map" has values: warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" option with "source-map" value: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" option with "source-map" value: errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" option with "source-map" value: source map 1`] = `
{
"mappings": "AAAA",
"names": [],
"sourceRoot": "",
"sources": [
"css/style.css",
],
"sourcesContent": [
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
",
],
"version": 3,
}
`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" option with "source-map" value: warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" with "false" value: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" with "false" value: errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" with "false" value: source map 1`] = `
{
"mappings": "AAAA",
"names": [],
"sourceRoot": "",
"sources": [
"css/style.css",
],
"sourcesContent": [
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
",
],
"version": 3,
}
`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" with "false" value: warnings 1`] = `[]`;
exports[`"sourceMap" option should not generate source maps when value is not specified and the "devtool" option with "source-map" value: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"sourceMap" option should not generate source maps when value is not specified and the "devtool" option with "source-map" value: errors 1`] = `[]`;
exports[`"sourceMap" option should not generate source maps when value is not specified and the "devtool" option with "source-map" value: warnings 1`] = `[]`;
exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "false" value: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "false" value: errors 1`] = `[]`;
exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "false" value: warnings 1`] = `[]`;
exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "source-map" value: css 1`] = `
"a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
"
`;
exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "source-map" value: errors 1`] = `[]`;
exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "source-map" value: warnings 1`] = `[]`;
postcss-loader-7.0.2/test/__snapshots__/validate-options.test.js.snap 0000664 0000000 0000000 00000020753 14341464453 0026034 0 ustar 00root root 0000000 0000000 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`validate options should throw an error on the "execute" option with "/test/" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.execute should be a boolean.
-> Enables/Disables PostCSS parser support in 'CSS-in-JS'.
-> Read more at https://github.com/webpack-contrib/postcss-loader#execute"
`;
exports[`validate options should throw an error on the "execute" option with "[]" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.execute should be a boolean.
-> Enables/Disables PostCSS parser support in 'CSS-in-JS'.
-> Read more at https://github.com/webpack-contrib/postcss-loader#execute"
`;
exports[`validate options should throw an error on the "execute" option with "{"foo":"bar"}" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.execute should be a boolean.
-> Enables/Disables PostCSS parser support in 'CSS-in-JS'.
-> Read more at https://github.com/webpack-contrib/postcss-loader#execute"
`;
exports[`validate options should throw an error on the "execute" option with "{}" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.execute should be a boolean.
-> Enables/Disables PostCSS parser support in 'CSS-in-JS'.
-> Read more at https://github.com/webpack-contrib/postcss-loader#execute"
`;
exports[`validate options should throw an error on the "execute" option with "1" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.execute should be a boolean.
-> Enables/Disables PostCSS parser support in 'CSS-in-JS'.
-> Read more at https://github.com/webpack-contrib/postcss-loader#execute"
`;
exports[`validate options should throw an error on the "execute" option with "test" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.execute should be a boolean.
-> Enables/Disables PostCSS parser support in 'CSS-in-JS'.
-> Read more at https://github.com/webpack-contrib/postcss-loader#execute"
`;
exports[`validate options should throw an error on the "implementation" option with "/test/" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.implementation should be one of these:
string | function
-> The implementation of postcss to use, instead of the locally installed version
-> Read more at https://github.com/webpack-contrib/postcss-loader#implementation
Details:
* options.implementation should be a string.
* options.implementation should be an instance of function."
`;
exports[`validate options should throw an error on the "implementation" option with "[]" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.implementation should be one of these:
string | function
-> The implementation of postcss to use, instead of the locally installed version
-> Read more at https://github.com/webpack-contrib/postcss-loader#implementation
Details:
* options.implementation should be a string.
* options.implementation should be an instance of function."
`;
exports[`validate options should throw an error on the "implementation" option with "{}" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.implementation should be one of these:
string | function
-> The implementation of postcss to use, instead of the locally installed version
-> Read more at https://github.com/webpack-contrib/postcss-loader#implementation
Details:
* options.implementation should be a string.
* options.implementation should be an instance of function."
`;
exports[`validate options should throw an error on the "implementation" option with "1" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.implementation should be one of these:
string | function
-> The implementation of postcss to use, instead of the locally installed version
-> Read more at https://github.com/webpack-contrib/postcss-loader#implementation
Details:
* options.implementation should be a string.
* options.implementation should be an instance of function."
`;
exports[`validate options should throw an error on the "postcssOptions" option with "{"config":[]}" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.postcssOptions should be one of these:
object { config?, … } | function
-> Options to pass through to \`Postcss\`.
-> Read more at https://github.com/webpack-contrib/postcss-loader#postcssOptions
Details:
* options.postcssOptions.config should be one of these:
string | boolean
-> Allows to specify PostCSS config path.
-> Read more at https://github.com/webpack-contrib/postcss-loader#config
Details:
* options.postcssOptions.config should be a string.
-> Allows to specify the path to the configuration file
* options.postcssOptions.config should be a boolean.
-> Enables/Disables autoloading config"
`;
exports[`validate options should throw an error on the "postcssOptions" option with "{"config":{}}" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.postcssOptions should be one of these:
object { config?, … } | function
-> Options to pass through to \`Postcss\`.
-> Read more at https://github.com/webpack-contrib/postcss-loader#postcssOptions
Details:
* options.postcssOptions.config should be one of these:
string | boolean
-> Allows to specify PostCSS config path.
-> Read more at https://github.com/webpack-contrib/postcss-loader#config
Details:
* options.postcssOptions.config should be a string.
-> Allows to specify the path to the configuration file
* options.postcssOptions.config should be a boolean.
-> Enables/Disables autoloading config"
`;
exports[`validate options should throw an error on the "sourceMap" option with "/test/" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.sourceMap should be a boolean.
-> Enables/Disables generation of source maps.
-> Read more at https://github.com/webpack-contrib/postcss-loader#sourcemap"
`;
exports[`validate options should throw an error on the "sourceMap" option with "[]" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.sourceMap should be a boolean.
-> Enables/Disables generation of source maps.
-> Read more at https://github.com/webpack-contrib/postcss-loader#sourcemap"
`;
exports[`validate options should throw an error on the "sourceMap" option with "{}" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.sourceMap should be a boolean.
-> Enables/Disables generation of source maps.
-> Read more at https://github.com/webpack-contrib/postcss-loader#sourcemap"
`;
exports[`validate options should throw an error on the "sourceMap" option with "1" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.sourceMap should be a boolean.
-> Enables/Disables generation of source maps.
-> Read more at https://github.com/webpack-contrib/postcss-loader#sourcemap"
`;
exports[`validate options should throw an error on the "sourceMap" option with "something" value 1`] = `
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options.sourceMap should be a boolean.
-> Enables/Disables generation of source maps.
-> Read more at https://github.com/webpack-contrib/postcss-loader#sourcemap"
`;
postcss-loader-7.0.2/test/cjs.test.js 0000664 0000000 0000000 00000000231 14341464453 0017540 0 ustar 00root root 0000000 0000000 import src from "../src";
import cjs from "../src/cjs";
describe("cjs", () => {
it("should exported", () => {
expect(cjs).toEqual(src);
});
});
postcss-loader-7.0.2/test/config-autoload.test.js 0000664 0000000 0000000 00000007726 14341464453 0022054 0 ustar 00root root 0000000 0000000 import path from "path";
import fs from "fs";
import { loadConfig } from "../src/utils";
const testDirectory = path.resolve(__dirname, "fixtures", "config-autoload");
const loaderContext = {
fs,
addBuildDependency: () => true,
addDependency: () => true,
};
describe("autoload config", () => {
it('should load ".postcssrc"', async () => {
const loadedConfig = await loadConfig(
loaderContext,
path.resolve(testDirectory, "rc")
);
expect(loadedConfig.config.map).toEqual(false);
expect(loadedConfig.config.from).toEqual("./test/rc/fixtures/index.css");
expect(loadedConfig.config.to).toEqual("./test/rc/expect/index.css");
expect(Object.keys(loadedConfig.config.plugins).length).toEqual(2);
expect(loadedConfig.filepath).toEqual(
path.resolve(testDirectory, "rc", ".postcssrc")
);
});
it('should load ".postcssrc.js"', async () => {
const loadedConfig = await loadConfig(
loaderContext,
path.resolve(testDirectory, "rc-js")
);
expect(loadedConfig.config.map).toEqual(false);
expect(loadedConfig.config.from).toEqual("./test/rc-js/fixtures/index.css");
expect(loadedConfig.config.to).toEqual("./test/rc-js/expect/index.css");
expect(Object.keys(loadedConfig.config.plugins).length).toEqual(2);
expect(loadedConfig.filepath).toEqual(
path.resolve(testDirectory, "rc-js", ".postcssrc.js")
);
});
it('should load "package.json"', async () => {
const loadedConfig = await loadConfig(
loaderContext,
path.resolve(testDirectory, "pkg")
);
expect(loadedConfig.config.parser).toEqual(false);
expect(loadedConfig.config.syntax).toEqual(false);
expect(loadedConfig.config.map).toEqual(false);
expect(loadedConfig.config.from).toEqual("./index.css");
expect(loadedConfig.config.to).toEqual("./index.css");
expect(Object.keys(loadedConfig.config.plugins).length).toEqual(2);
expect(loadedConfig.filepath).toEqual(
path.resolve(testDirectory, "pkg", "package.json")
);
});
it('should load "postcss.config.js" with "Object" syntax of plugins', async () => {
const loadedConfig = await loadConfig(
loaderContext,
path.resolve(testDirectory, "js/object")
);
expect(loadedConfig.config.map).toEqual(false);
expect(loadedConfig.config.from).toEqual(
"./test/fixtures/config-autoload/js/object/index.css"
);
expect(loadedConfig.config.to).toEqual(
"./test/fixtures/config-autoload/js/object/expect/index.css"
);
expect(Object.keys(loadedConfig.config.plugins).length).toEqual(2);
expect(loadedConfig.filepath).toEqual(
path.resolve(testDirectory, "js/object", "postcss.config.js")
);
});
it('should load "postcss.config.js" with "Array" syntax of plugins', async () => {
const loadedConfig = await loadConfig(
loaderContext,
path.resolve(testDirectory, "js/array")
);
expect(loadedConfig.config.map).toEqual(false);
expect(loadedConfig.config.from).toEqual(
"./test/fixtures/config-autoload/js/object/index.css"
);
expect(loadedConfig.config.to).toEqual(
"./test/fixtures/config-autoload/js/object/expect/index.css"
);
expect(Object.keys(loadedConfig.config.plugins).length).toEqual(4);
expect(loadedConfig.filepath).toEqual(
path.resolve(testDirectory, "js/array", "postcss.config.js")
);
});
it('should load empty ".postcssrc"', async () => {
const loadedConfig = await loadConfig(
loaderContext,
path.resolve(testDirectory, "empty/.postcssrc")
);
// eslint-disable-next-line no-undefined
expect(loadedConfig.config).toEqual(undefined);
expect(loadedConfig.filepath).toEqual(
path.resolve(testDirectory, "empty/.postcssrc")
);
});
it('should throw an error on "unresolved" config', async () => {
try {
await loadConfig(loaderContext, path.resolve("unresolved"));
} catch (error) {
expect(error.message).toMatch(/^No PostCSS config found in: (.*)$/);
}
});
});
postcss-loader-7.0.2/test/execute.test.js 0000664 0000000 0000000 00000006351 14341464453 0020434 0 ustar 00root root 0000000 0000000 import path from "path";
import {
compile,
getCompiler,
getErrors,
getCodeFromBundle,
getWarnings,
} from "./helpers";
describe('"execute" option', () => {
it('should work with "Boolean" value', async () => {
const compiler = getCompiler(
"./jss/exec/index.js",
{},
{
module: {
rules: [
{
test: /style\.(exec\.js|js)$/i,
use: [
{
loader: require.resolve("./helpers/testLoader"),
options: {},
},
{
loader: path.resolve(__dirname, "../src"),
options: {
execute: true,
},
},
],
},
],
},
}
);
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.exec.js", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with "postcss-js" parser', async () => {
const compiler = getCompiler(
"./jss/postcss-js/index.js",
{},
{
module: {
rules: [
{
test: /style\.js$/i,
use: [
{
loader: require.resolve("./helpers/testLoader"),
options: {},
},
{
loader: path.resolve(__dirname, "../src"),
options: {
postcssOptions: {
parser: "postcss-js",
},
execute: true,
},
},
],
},
],
},
}
);
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.js", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it("should reuse PostCSS AST with JS styles", async () => {
const spy = jest.fn();
const compiler = getCompiler(
"./jss/exec/index.js",
{},
{
module: {
rules: [
{
test: /style\.(exec\.js|js)$/i,
use: [
{
loader: require.resolve("./helpers/testLoader"),
options: {},
},
{
loader: path.resolve(__dirname, "../src"),
options: {
execute: true,
},
},
{
loader: require.resolve("./helpers/astLoader"),
options: { spy, execute: true },
},
],
},
],
},
}
);
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.exec.js", stats);
expect(spy).toHaveBeenCalledTimes(1);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
});
postcss-loader-7.0.2/test/fixtures/ 0000775 0000000 0000000 00000000000 14341464453 0017322 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/ 0000775 0000000 0000000 00000000000 14341464453 0022375 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/empty/ 0000775 0000000 0000000 00000000000 14341464453 0023533 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/empty/.postcssrc 0000664 0000000 0000000 00000000001 14341464453 0025546 0 ustar 00root root 0000000 0000000
postcss-loader-7.0.2/test/fixtures/config-autoload/empty/expect/ 0000775 0000000 0000000 00000000000 14341464453 0025023 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/empty/expect/index.css 0000664 0000000 0000000 00000000064 14341464453 0026644 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
.test {
color: blue;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/empty/expect/index.sss 0000664 0000000 0000000 00000000062 14341464453 0026662 0 ustar 00root root 0000000 0000000 .import {
color: red
}
.test {
color: blue
}
postcss-loader-7.0.2/test/fixtures/config-autoload/empty/fixtures/ 0000775 0000000 0000000 00000000000 14341464453 0025404 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/empty/fixtures/imports/ 0000775 0000000 0000000 00000000000 14341464453 0027101 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/empty/fixtures/imports/section.css 0000664 0000000 0000000 00000000032 14341464453 0031252 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/empty/fixtures/imports/section.sss 0000664 0000000 0000000 00000000025 14341464453 0031274 0 ustar 00root root 0000000 0000000 .import
color: red
postcss-loader-7.0.2/test/fixtures/config-autoload/empty/fixtures/index.css 0000664 0000000 0000000 00000000071 14341464453 0027223 0 ustar 00root root 0000000 0000000 @import "imports/section.css";
.test {
color: blue;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/empty/fixtures/index.sss 0000664 0000000 0000000 00000000063 14341464453 0027244 0 ustar 00root root 0000000 0000000 @import "imports/section.sss"
.test
color: blue
postcss-loader-7.0.2/test/fixtures/config-autoload/err/ 0000775 0000000 0000000 00000000000 14341464453 0023165 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/err/options/ 0000775 0000000 0000000 00000000000 14341464453 0024660 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/err/options/parser/ 0000775 0000000 0000000 00000000000 14341464453 0026154 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/err/options/parser/.postcssrc.js 0000664 0000000 0000000 00000000116 14341464453 0030611 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
parser: 'postcss-parser'
}
};
postcss-loader-7.0.2/test/fixtures/config-autoload/err/options/stringifier/ 0000775 0000000 0000000 00000000000 14341464453 0027205 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/err/options/stringifier/.postcssrc.js 0000664 0000000 0000000 00000000130 14341464453 0031636 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
stringifier: 'postcss-stringifier'
}
};
postcss-loader-7.0.2/test/fixtures/config-autoload/err/options/syntax/ 0000775 0000000 0000000 00000000000 14341464453 0026206 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/err/options/syntax/.postcssrc.js 0000664 0000000 0000000 00000000116 14341464453 0030643 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
syntax: 'postcss-syntax'
}
};
postcss-loader-7.0.2/test/fixtures/config-autoload/err/plugins/ 0000775 0000000 0000000 00000000000 14341464453 0024646 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/err/plugins/.postcssrc.js 0000664 0000000 0000000 00000000140 14341464453 0027300 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
plugins: [
require('./plugin')
]
}
};
postcss-loader-7.0.2/test/fixtures/config-autoload/err/plugins/array/ 0000775 0000000 0000000 00000000000 14341464453 0025764 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/err/plugins/array/.postcssrc.js 0000664 0000000 0000000 00000000146 14341464453 0030424 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
plugins: [
require('postcss-plugin')
]
}
};
postcss-loader-7.0.2/test/fixtures/config-autoload/err/plugins/array/options/ 0000775 0000000 0000000 00000000000 14341464453 0027457 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/err/plugins/array/options/.postcssrc.js 0000664 0000000 0000000 00000000146 14341464453 0032117 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
plugins: [
require('postcss-plugin')
]
}
};
postcss-loader-7.0.2/test/fixtures/config-autoload/err/plugins/object/ 0000775 0000000 0000000 00000000000 14341464453 0026114 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/err/plugins/object/.postcssrc.js 0000664 0000000 0000000 00000000141 14341464453 0030547 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
plugins: {
'postcss-plugin': {}
}
}
};
postcss-loader-7.0.2/test/fixtures/config-autoload/err/plugins/object/options/ 0000775 0000000 0000000 00000000000 14341464453 0027607 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/err/plugins/object/options/.postcssrc.js 0000664 0000000 0000000 00000000157 14341464453 0032251 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
plugins: {
'postcss-plugin': { option: true }
}
}
};
postcss-loader-7.0.2/test/fixtures/config-autoload/err/plugins/plugin.js 0000664 0000000 0000000 00000000043 14341464453 0026477 0 ustar 00root root 0000000 0000000 module.exports = 'Invalid Plugin';
postcss-loader-7.0.2/test/fixtures/config-autoload/js/ 0000775 0000000 0000000 00000000000 14341464453 0023011 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/js/array/ 0000775 0000000 0000000 00000000000 14341464453 0024127 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/js/array/imports/ 0000775 0000000 0000000 00000000000 14341464453 0025624 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/js/array/imports/section.css 0000664 0000000 0000000 00000000040 14341464453 0027774 0 ustar 00root root 0000000 0000000 .import {
color: goldenrod;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/js/array/index.css 0000664 0000000 0000000 00000000071 14341464453 0025746 0 ustar 00root root 0000000 0000000 @import 'imports/section.css';
.test {
color: cyan;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/js/array/index.js 0000664 0000000 0000000 00000000066 14341464453 0025576 0 ustar 00root root 0000000 0000000 import style from './index.css'
export default style
postcss-loader-7.0.2/test/fixtures/config-autoload/js/array/postcss.config.js 0000664 0000000 0000000 00000000767 14341464453 0027441 0 ustar 00root root 0000000 0000000 module.exports = function (api) {
return {
parser: 'sugarss',
syntax: 'sugarss',
map: api.mode === 'development' ? 'inline' : false,
from: './test/fixtures/config-autoload/js/object/index.css',
to: './test/fixtures/config-autoload/js/object/expect/index.css',
plugins: [
'postcss-import',
[
'postcss-nested',
{
// Options
}
],
require('postcss-nested'),
require('postcss-nested')({ /* Options */ }),
]
}
};
postcss-loader-7.0.2/test/fixtures/config-autoload/js/object/ 0000775 0000000 0000000 00000000000 14341464453 0024257 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/js/object/imports/ 0000775 0000000 0000000 00000000000 14341464453 0025754 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/js/object/imports/section.css 0000664 0000000 0000000 00000000032 14341464453 0030125 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/js/object/index.css 0000664 0000000 0000000 00000000071 14341464453 0026076 0 ustar 00root root 0000000 0000000 @import "imports/section.css";
.test {
color: blue;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/js/object/index.js 0000664 0000000 0000000 00000000066 14341464453 0025726 0 ustar 00root root 0000000 0000000 import style from './index.css'
export default style
postcss-loader-7.0.2/test/fixtures/config-autoload/js/object/postcss.config.js 0000664 0000000 0000000 00000000556 14341464453 0027565 0 ustar 00root root 0000000 0000000 module.exports = function (api) {
return {
parser: 'sugarss',
syntax: 'sugarss',
map: api.mode === 'development' ? 'inline' : false,
from: './test/fixtures/config-autoload/js/object/index.css',
to: './test/fixtures/config-autoload/js/object/expect/index.css',
plugins: {
'postcss-import': {},
'postcss-nested': {},
}
}
};
postcss-loader-7.0.2/test/fixtures/config-autoload/pkg/ 0000775 0000000 0000000 00000000000 14341464453 0023156 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/pkg/imports/ 0000775 0000000 0000000 00000000000 14341464453 0024653 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/pkg/imports/section.css 0000664 0000000 0000000 00000000032 14341464453 0027024 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/pkg/index.css 0000664 0000000 0000000 00000000071 14341464453 0024775 0 ustar 00root root 0000000 0000000 @import "imports/section.css";
.test {
color: blue;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/pkg/index.js 0000664 0000000 0000000 00000000066 14341464453 0024625 0 ustar 00root root 0000000 0000000 import style from './index.css'
export default style
postcss-loader-7.0.2/test/fixtures/config-autoload/pkg/package.json 0000664 0000000 0000000 00000000405 14341464453 0025443 0 ustar 00root root 0000000 0000000 {
"name": "postcss-config",
"version": "1.0.0",
"postcss": {
"parser": false,
"syntax": false,
"map": false,
"from": "./index.css",
"to": "./index.css",
"plugins": [
"postcss-import",
["postcss-nested", {}]
]
}
}
postcss-loader-7.0.2/test/fixtures/config-autoload/rc-js/ 0000775 0000000 0000000 00000000000 14341464453 0023413 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/rc-js/.postcssrc.js 0000664 0000000 0000000 00000000356 14341464453 0026056 0 ustar 00root root 0000000 0000000 module.exports = {
"parser": "sugarss",
"syntax": "sugarss",
"map": false,
"from": "./test/rc-js/fixtures/index.css",
"to": "./test/rc-js/expect/index.css",
"plugins": [
"postcss-import",
["postcss-nested", {}]
]
};
postcss-loader-7.0.2/test/fixtures/config-autoload/rc-js/expect/ 0000775 0000000 0000000 00000000000 14341464453 0024703 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/rc-js/expect/index.css 0000664 0000000 0000000 00000000064 14341464453 0026524 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
.test {
color: blue;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/rc-js/expect/index.sss 0000664 0000000 0000000 00000000062 14341464453 0026542 0 ustar 00root root 0000000 0000000 .import {
color: red
}
.test {
color: blue
}
postcss-loader-7.0.2/test/fixtures/config-autoload/rc-js/fixtures/ 0000775 0000000 0000000 00000000000 14341464453 0025264 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/rc-js/fixtures/imports/ 0000775 0000000 0000000 00000000000 14341464453 0026761 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/rc-js/fixtures/imports/section.css 0000664 0000000 0000000 00000000032 14341464453 0031132 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/rc-js/fixtures/imports/section.sss 0000664 0000000 0000000 00000000025 14341464453 0031154 0 ustar 00root root 0000000 0000000 .import
color: red
postcss-loader-7.0.2/test/fixtures/config-autoload/rc-js/fixtures/index.css 0000664 0000000 0000000 00000000071 14341464453 0027103 0 ustar 00root root 0000000 0000000 @import "imports/section.css";
.test {
color: blue;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/rc-js/fixtures/index.sss 0000664 0000000 0000000 00000000063 14341464453 0027124 0 ustar 00root root 0000000 0000000 @import "imports/section.sss"
.test
color: blue
postcss-loader-7.0.2/test/fixtures/config-autoload/rc/ 0000775 0000000 0000000 00000000000 14341464453 0023001 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/rc/.postcssrc 0000664 0000000 0000000 00000000326 14341464453 0025026 0 ustar 00root root 0000000 0000000 {
"parser": "sugarss",
"syntax": "sugarss",
"map": false,
"from": "./test/rc/fixtures/index.css",
"to": "./test/rc/expect/index.css",
"plugins": [
"postcss-import",
["postcss-nested", {}]
]
}
postcss-loader-7.0.2/test/fixtures/config-autoload/rc/expect/ 0000775 0000000 0000000 00000000000 14341464453 0024271 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/rc/expect/index.css 0000664 0000000 0000000 00000000064 14341464453 0026112 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
.test {
color: blue;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/rc/expect/index.sss 0000664 0000000 0000000 00000000062 14341464453 0026130 0 ustar 00root root 0000000 0000000 .import {
color: red
}
.test {
color: blue
}
postcss-loader-7.0.2/test/fixtures/config-autoload/rc/fixtures/ 0000775 0000000 0000000 00000000000 14341464453 0024652 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/rc/fixtures/imports/ 0000775 0000000 0000000 00000000000 14341464453 0026347 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-autoload/rc/fixtures/imports/section.css 0000664 0000000 0000000 00000000032 14341464453 0030520 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/rc/fixtures/imports/section.sss 0000664 0000000 0000000 00000000025 14341464453 0030542 0 ustar 00root root 0000000 0000000 .import
color: red
postcss-loader-7.0.2/test/fixtures/config-autoload/rc/fixtures/index.css 0000664 0000000 0000000 00000000071 14341464453 0026471 0 ustar 00root root 0000000 0000000 @import "imports/section.css";
.test {
color: blue;
}
postcss-loader-7.0.2/test/fixtures/config-autoload/rc/fixtures/index.sss 0000664 0000000 0000000 00000000063 14341464453 0026512 0 ustar 00root root 0000000 0000000 @import "imports/section.sss"
.test
color: blue
postcss-loader-7.0.2/test/fixtures/config-scope/ 0000775 0000000 0000000 00000000000 14341464453 0021676 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-scope/all-options/ 0000775 0000000 0000000 00000000000 14341464453 0024137 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-scope/all-options/postcss.config.js 0000664 0000000 0000000 00000000456 14341464453 0027444 0 ustar 00root root 0000000 0000000 const path = require('path');
module.exports = () => ({
from: path.resolve(__dirname, '../../sss/style.sss'),
to: path.resolve(__dirname, '../../sss/style.css'),
parser: 'sugarss',
map: {
inline: true,
annotation: true,
},
plugins: [
['postcss-short', { prefix: 'x' }]
]
});
postcss-loader-7.0.2/test/fixtures/config-scope/api/ 0000775 0000000 0000000 00000000000 14341464453 0022447 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-scope/api/postcss.config.js 0000664 0000000 0000000 00000001004 14341464453 0025742 0 ustar 00root root 0000000 0000000 module.exports = function (api) {
if (!api.mode) {
throw new Error(`Failed, no ${api.mode} API`);
}
if (!api.file) {
throw new Error(`Failed, no ${api.file} API`);
}
if (!api.webpackLoaderContext) {
throw new Error(`Failed, no ${api.webpackLoaderContext} API`);
}
if (!api.env) {
throw new Error(`Failed, no ${api.env} API`);
}
if (!api.options) {
throw new Error(`Failed, no ${api.options} API`);
}
return {
plugins: [['postcss-short', { prefix: 'x' }]],
}
};
postcss-loader-7.0.2/test/fixtures/config-scope/config/ 0000775 0000000 0000000 00000000000 14341464453 0023143 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-scope/config/context/ 0000775 0000000 0000000 00000000000 14341464453 0024627 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-scope/config/context/plugin.js 0000664 0000000 0000000 00000000427 14341464453 0026466 0 ustar 00root root 0000000 0000000 const postcss = require('postcss');
const customPlugin = (ctx) => (css, result) => {
ctx.webpack._compilation.assets['asset.txt'] = {
source () {
return '123'
},
size () {
return 0
}
}
};
module.exports = postcss.plugin('plugin', customPlugin);
postcss-loader-7.0.2/test/fixtures/config-scope/config/context/postcss.config.js 0000664 0000000 0000000 00000000117 14341464453 0030126 0 ustar 00root root 0000000 0000000 module.exports = (ctx) => ({
plugins: [
require('./plugin')(ctx)
]
});
postcss-loader-7.0.2/test/fixtures/config-scope/config/plugin.js 0000664 0000000 0000000 00000000525 14341464453 0025001 0 ustar 00root root 0000000 0000000 'use strict';
const postcss = require('postcss');
module.exports = postcss.plugin('plugin', (options) => {
options = Object.assign({ alpha: '1.0' }, options);
return (css, result) => {
css.walkDecls((decl) => {
if (decl.value === 'black') {
decl.value = 'rgba(0, 0, 0, ' + options.alpha + ')'
}
})
}
});
postcss-loader-7.0.2/test/fixtures/config-scope/config/postcss.config.js 0000664 0000000 0000000 00000000111 14341464453 0026434 0 ustar 00root root 0000000 0000000 module.exports = () => ({
plugins: [
require('./plugin')()
]
});
postcss-loader-7.0.2/test/fixtures/config-scope/css/ 0000775 0000000 0000000 00000000000 14341464453 0022466 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-scope/css/custom.config.js 0000664 0000000 0000000 00000000112 14341464453 0025574 0 ustar 00root root 0000000 0000000 module.exports = {
plugins: [
require('../config/plugin')()
]
};
postcss-loader-7.0.2/test/fixtures/config-scope/css/index.js 0000664 0000000 0000000 00000000066 14341464453 0024135 0 ustar 00root root 0000000 0000000 import style from './style.css'
export default style
postcss-loader-7.0.2/test/fixtures/config-scope/css/index2.js 0000664 0000000 0000000 00000000067 14341464453 0024220 0 ustar 00root root 0000000 0000000 import style from './style2.css'
export default style
postcss-loader-7.0.2/test/fixtures/config-scope/css/invalid.config.js 0000664 0000000 0000000 00000000053 14341464453 0025714 0 ustar 00root root 0000000 0000000 throw new Error('invalid postcss config');
postcss-loader-7.0.2/test/fixtures/config-scope/css/plugins.config.js 0000664 0000000 0000000 00000000201 14341464453 0025742 0 ustar 00root root 0000000 0000000 module.exports = {
plugins: {
'postcss-short': { prefix: 'x' },
'postcss-import': {},
'postcss-nested': {},
}
};
postcss-loader-7.0.2/test/fixtures/config-scope/css/style.css 0000664 0000000 0000000 00000000055 14341464453 0024340 0 ustar 00root root 0000000 0000000 a { color: black }
.foo {
float: right;
}
postcss-loader-7.0.2/test/fixtures/config-scope/css/style2.css 0000664 0000000 0000000 00000000075 14341464453 0024424 0 ustar 00root root 0000000 0000000 a {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
postcss-loader-7.0.2/test/fixtures/config-scope/from-to/ 0000775 0000000 0000000 00000000000 14341464453 0023261 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-scope/from-to/postcss.config.js 0000664 0000000 0000000 00000000334 14341464453 0026561 0 ustar 00root root 0000000 0000000 module.exports = {
from: '../../css/style.css',
to: '../../css/style.css',
map: {
inline: false,
annotation: false,
sourcesContent: true,
},
plugins: [
['postcss-short', { prefix: 'x' }]
]
};
postcss-loader-7.0.2/test/fixtures/config-scope/postcss.config.js 0000664 0000000 0000000 00000000111 14341464453 0025167 0 ustar 00root root 0000000 0000000 module.exports = {
plugins: [
require('./config/plugin')()
]
};
postcss-loader-7.0.2/test/fixtures/config-scope/with-config/ 0000775 0000000 0000000 00000000000 14341464453 0024114 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/config-scope/with-config/index.js 0000664 0000000 0000000 00000000066 14341464453 0025563 0 ustar 00root root 0000000 0000000 import style from './style.css'
export default style
postcss-loader-7.0.2/test/fixtures/config-scope/with-config/postcss.config.js 0000664 0000000 0000000 00000000144 14341464453 0027413 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
plugins: [['postcss-short', { prefix: 'x' }]],
}
};
postcss-loader-7.0.2/test/fixtures/config-scope/with-config/style.css 0000664 0000000 0000000 00000000410 14341464453 0025761 0 ustar 00root root 0000000 0000000 a { color: black }
.foo {
float: right;
}
.bar {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
@media (prefers-color-scheme: dark) {
:root { /* :root is for HTML documents */
--text-color: white
}
body {
background: black
}
} postcss-loader-7.0.2/test/fixtures/css/ 0000775 0000000 0000000 00000000000 14341464453 0020112 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/css/index.js 0000664 0000000 0000000 00000000070 14341464453 0021554 0 ustar 00root root 0000000 0000000 import style from './style.css';
export default style;
postcss-loader-7.0.2/test/fixtures/css/plugins.config.js 0000664 0000000 0000000 00000000115 14341464453 0023372 0 ustar 00root root 0000000 0000000 module.exports = {
plugins: {
'postcss-short': { prefix: 'x' },
}
};
postcss-loader-7.0.2/test/fixtures/css/style.css 0000664 0000000 0000000 00000000633 14341464453 0021766 0 ustar 00root root 0000000 0000000 a {
color: black;
}
a {
color: red;
}
a {
color: green;
}
a {
color: blue;
}
.class {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
.class-foo {
-z-border-color: blue blue *;
-z-color: * #fafafa;
}
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}
postcss-loader-7.0.2/test/fixtures/esparser/ 0000775 0000000 0000000 00000000000 14341464453 0021146 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/esparser/index.mjs 0000664 0000000 0000000 00000000157 14341464453 0022773 0 ustar 00root root 0000000 0000000 function stringify() {
return "";
}
function parse() {
return "";
}
export default { stringify, parse };
postcss-loader-7.0.2/test/fixtures/esparser/package.json 0000664 0000000 0000000 00000000241 14341464453 0023431 0 ustar 00root root 0000000 0000000 {
"type": "module",
"exports": {
".": {
"require": "./index.js",
"import": "./index.mjs"
}
},
"name": "test",
"version": "1.0.0"
}
postcss-loader-7.0.2/test/fixtures/esparser/runManual.mjs 0000664 0000000 0000000 00000002214 14341464453 0023622 0 ustar 00root root 0000000 0000000 import webpack from 'webpack';
import path from "path";
const __dirname = path.resolve();
const rootDir = path.resolve(__dirname, "test/helpers");
const compiler = webpack({
target: 'node',
mode: "development",
devtool: false,
context: path.resolve(rootDir, "../fixtures"),
entry: path.resolve(rootDir, "../fixtures", "./sss/index.js"),
output: {
path: path.resolve(rootDir, "../outputs"),
filename: "[name].bundle.js",
chunkFilename: "[name].chunk.js",
publicPath: "/webpack/public/path/",
},
module: {
rules: [
{
test: /\.(css|sss)$/i,
use: [
'css-loader',
{
loader: path.resolve(rootDir, "../../dist"),
options: {
postcssOptions: {
parser: path.resolve(rootDir, "../fixtures/esparser/index.mjs"),
stringifier: path.resolve(rootDir, "../fixtures/esparser/index.mjs"),
syntax: path.resolve(rootDir, "../fixtures/esparser/index.mjs"),
},
},
},
],
},
],
},
plugins: [],
});
compiler.run((error) => {
if (error) {
throw error;
}
});
postcss-loader-7.0.2/test/fixtures/jss/ 0000775 0000000 0000000 00000000000 14341464453 0020121 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/jss/exec/ 0000775 0000000 0000000 00000000000 14341464453 0021045 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/jss/exec/index.js 0000664 0000000 0000000 00000000074 14341464453 0022513 0 ustar 00root root 0000000 0000000 import style from './style.exec.js';
export default style;
postcss-loader-7.0.2/test/fixtures/jss/exec/style.exec.js 0000664 0000000 0000000 00000000224 14341464453 0023464 0 ustar 00root root 0000000 0000000 'use strict';
const postcssJS = require('postcss-js');
const style = {
a: {
color: 'green'
}
};
module.exports = postcssJS.parse(style);
postcss-loader-7.0.2/test/fixtures/jss/postcss-js/ 0000775 0000000 0000000 00000000000 14341464453 0022231 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/jss/postcss-js/index.js 0000664 0000000 0000000 00000000065 14341464453 0023677 0 ustar 00root root 0000000 0000000 import style from './style.js'
export default style
postcss-loader-7.0.2/test/fixtures/jss/postcss-js/style.js 0000664 0000000 0000000 00000000054 14341464453 0023726 0 ustar 00root root 0000000 0000000 module.exports = { a: { color: 'yellow' } }
postcss-loader-7.0.2/test/fixtures/less/ 0000775 0000000 0000000 00000000000 14341464453 0020270 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/less/index.js 0000664 0000000 0000000 00000000067 14341464453 0021740 0 ustar 00root root 0000000 0000000 import style from './style.less'
export default style
postcss-loader-7.0.2/test/fixtures/less/style.less 0000664 0000000 0000000 00000000023 14341464453 0022313 0 ustar 00root root 0000000 0000000 a { color: coral }
postcss-loader-7.0.2/test/fixtures/package-json-files/ 0000775 0000000 0000000 00000000000 14341464453 0022764 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/package-json-files/no-postcss/ 0000775 0000000 0000000 00000000000 14341464453 0025074 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/package-json-files/no-postcss/package.json 0000664 0000000 0000000 00000000061 14341464453 0027357 0 ustar 00root root 0000000 0000000 {
"dependencies": {},
"devDependencies": {}
} postcss-loader-7.0.2/test/fixtures/package-json-files/postcss-v8-in-dependencies/ 0000775 0000000 0000000 00000000000 14341464453 0030045 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/package-json-files/postcss-v8-in-dependencies/package.json 0000664 0000000 0000000 00000000114 14341464453 0032327 0 ustar 00root root 0000000 0000000 {
"dependencies": {
"postcss": "^8.0.0"
},
"devDependencies": {}
} postcss-loader-7.0.2/test/fixtures/package-json-files/postcss-v8-in-devDependencies/ 0000775 0000000 0000000 00000000000 14341464453 0030504 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/package-json-files/postcss-v8-in-devDependencies/package.json 0000664 0000000 0000000 00000000114 14341464453 0032766 0 ustar 00root root 0000000 0000000 {
"dependencies": {},
"devDependencies": {
"postcss": "^8.0.0"
}
} postcss-loader-7.0.2/test/fixtures/plugin/ 0000775 0000000 0000000 00000000000 14341464453 0020620 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/plugin/default-other-plugin.js 0000664 0000000 0000000 00000000607 14341464453 0025220 0 ustar 00root root 0000000 0000000 'use strict';
const postcss = require('postcss');
module.exports = {
default: postcss.plugin('my-plugin', (options) => {
options = { alpha: '1.0', color: 'blue', ...options };
return (root, result) => {
root.walkDecls((decl) => {
if (decl.value === options.color) {
decl.value = 'rgba(0, 0, 255, ' + options.alpha + ')'
}
})
}
}),
};
postcss-loader-7.0.2/test/fixtures/plugin/new-api.plugin.js 0000664 0000000 0000000 00000000333 14341464453 0024012 0 ustar 00root root 0000000 0000000 module.exports = (opts = {}) => {
return {
postcssPlugin: 'postcss-new-api-plugin',
Declaration: {
width: (node) => {
node.value = '100px';
},
},
};
};
module.exports.postcss = true;
postcss-loader-7.0.2/test/fixtures/plugin/other-plugin.js 0000664 0000000 0000000 00000000533 14341464453 0023574 0 ustar 00root root 0000000 0000000 'use strict';
const postcss = require('postcss');
module.exports = postcss.plugin('my-plugin', (options) => {
options = Object.assign({ alpha: '1.0' }, options);
return (root, result) => {
root.walkDecls((decl) => {
if (decl.value === 'blue') {
decl.value = 'rgba(0, 0, 255, ' + options.alpha + ')'
}
})
}
});
postcss-loader-7.0.2/test/fixtures/plugin/plugin.js 0000664 0000000 0000000 00000000565 14341464453 0022462 0 ustar 00root root 0000000 0000000 'use strict';
const postcss = require('postcss');
module.exports = postcss.plugin('my-plugin', (options) => {
const myOptions = {...{ alpha: '1.0', color: 'black' }, ...options};
return (root, result) => {
root.walkDecls((decl) => {
if (decl.value === myOptions.color) {
decl.value = 'rgba(0, 0, 0, ' + myOptions.alpha + ')'
}
})
}
});
postcss-loader-7.0.2/test/fixtures/scss/ 0000775 0000000 0000000 00000000000 14341464453 0020275 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/scss/index.js 0000664 0000000 0000000 00000000067 14341464453 0021745 0 ustar 00root root 0000000 0000000 import style from './style.scss'
export default style
postcss-loader-7.0.2/test/fixtures/scss/style.scss 0000664 0000000 0000000 00000000023 14341464453 0022325 0 ustar 00root root 0000000 0000000 a { color: coral }
postcss-loader-7.0.2/test/fixtures/sss/ 0000775 0000000 0000000 00000000000 14341464453 0020132 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/fixtures/sss/index.js 0000664 0000000 0000000 00000000066 14341464453 0021601 0 ustar 00root root 0000000 0000000 import style from './style.sss'
export default style
postcss-loader-7.0.2/test/fixtures/sss/style.sss 0000664 0000000 0000000 00000000021 14341464453 0022015 0 ustar 00root root 0000000 0000000 a
color: black
postcss-loader-7.0.2/test/helpers/ 0000775 0000000 0000000 00000000000 14341464453 0017113 5 ustar 00root root 0000000 0000000 postcss-loader-7.0.2/test/helpers/astLoader.js 0000664 0000000 0000000 00000002061 14341464453 0021366 0 ustar 00root root 0000000 0000000 import Module from "module";
const postcss = require("postcss");
const parentModule = module;
function exec(code, loaderContext) {
const { resource, context } = loaderContext;
const module = new Module(resource, parentModule);
// eslint-disable-next-line no-underscore-dangle
module.paths = Module._nodeModulePaths(context);
module.filename = resource;
// eslint-disable-next-line no-underscore-dangle
module._compile(code, resource);
return module.exports;
}
module.exports = function astLoader(content) {
const callback = this.async();
const { spy = jest.fn(), execute } = this.query;
if (execute) {
// eslint-disable-next-line no-param-reassign
content = exec(content, this);
}
postcss()
.process(content)
.then((result) => {
const ast = {
type: "postcss",
version: result.processor.version,
root: result.root,
};
Object.defineProperty(ast, "root", {
get: spy.mockReturnValue(result.root),
});
callback(null, result.css, result.map, { ast });
});
};
postcss-loader-7.0.2/test/helpers/compile.js 0000664 0000000 0000000 00000000314 14341464453 0021077 0 ustar 00root root 0000000 0000000 export default (compiler) =>
new Promise((resolve, reject) => {
compiler.run((error, stats) => {
if (error) {
return reject(error);
}
return resolve(stats);
});
});
postcss-loader-7.0.2/test/helpers/execute.js 0000664 0000000 0000000 00000001037 14341464453 0021114 0 ustar 00root root 0000000 0000000 import Module from "module";
import path from "path";
const parentModule = module;
export default (code) => {
const resource = "test.js";
const module = new Module(resource, parentModule);
// eslint-disable-next-line no-underscore-dangle
module.paths = Module._nodeModulePaths(
path.resolve(__dirname, "../fixtures")
);
module.filename = resource;
// eslint-disable-next-line no-underscore-dangle
module._compile(
`let __export__;${code};module.exports = __export__;`,
resource
);
return module.exports;
};
postcss-loader-7.0.2/test/helpers/getCodeFromBundle.js 0000664 0000000 0000000 00000000763 14341464453 0023007 0 ustar 00root root 0000000 0000000 export default (id, stats) => {
const { modules } = stats.compilation;
const module = modules.find((m) => m.id.endsWith(id));
const { _source } = module;
// eslint-disable-next-line no-underscore-dangle
const code = (_source._value || _source._valueAsString).replace(
"module.exports = ",
""
);
let result;
try {
result = JSON.parse(code);
} catch (error) {
result = { css: code };
}
const { css, map: sourceMap } = result;
return { css, sourceMap };
};
postcss-loader-7.0.2/test/helpers/getCompiler.js 0000664 0000000 0000000 00000002412 14341464453 0021722 0 ustar 00root root 0000000 0000000 import path from "path";
import webpack from "webpack";
import { createFsFromVolume, Volume } from "memfs";
export default (fixture, loaderOptions = {}, config = {}) => {
const fullConfig = {
mode: "development",
devtool: config.devtool || false,
context: path.resolve(__dirname, "../fixtures"),
entry: path.resolve(__dirname, "../fixtures", fixture),
output: {
path: path.resolve(__dirname, "../outputs"),
filename: "[name].bundle.js",
chunkFilename: "[name].chunk.js",
publicPath: "/webpack/public/path/",
},
module: {
rules: [
{
test: /\.(css|sss)$/i,
use: [
{
loader: require.resolve("./testLoader"),
options: {},
},
{
loader: path.resolve(__dirname, "../../src"),
options: loaderOptions || {},
},
],
},
],
},
plugins: [],
...config,
};
const compiler = webpack(fullConfig);
if (!config.outputFileSystem) {
const outputFileSystem = createFsFromVolume(new Volume());
// Todo remove when we drop webpack@4 support
outputFileSystem.join = path.join.bind(path);
compiler.outputFileSystem = outputFileSystem;
}
return compiler;
};
postcss-loader-7.0.2/test/helpers/getErrors.js 0000664 0000000 0000000 00000000230 14341464453 0021420 0 ustar 00root root 0000000 0000000 import normalizeErrors from "./normalizeErrors";
export default (stats, shortError) =>
normalizeErrors(stats.compilation.errors, shortError).sort();
postcss-loader-7.0.2/test/helpers/getExecutedCode.js 0000664 0000000 0000000 00000000670 14341464453 0022515 0 ustar 00root root 0000000 0000000 import { execute, readAsset } from "./index";
export default (asset, compiler, stats) => {
let executed = execute(readAsset(asset, compiler, stats));
if (Array.isArray(executed)) {
executed = executed.map((module) => {
// Todo remove after drop webpack@4
// eslint-disable-next-line no-param-reassign
module[0] = module[0].replace(/\?.*!/g, "?[ident]!");
return module;
});
}
return executed;
};
postcss-loader-7.0.2/test/helpers/getWarnings.js 0000664 0000000 0000000 00000000200 14341464453 0021731 0 ustar 00root root 0000000 0000000 import normalizeErrors from "./normalizeErrors";
export default (stats) => normalizeErrors(stats.compilation.warnings).sort();
postcss-loader-7.0.2/test/helpers/index.js 0000664 0000000 0000000 00000001102 14341464453 0020552 0 ustar 00root root 0000000 0000000 import compile from "./compile";
import execute from "./execute";
import getCompiler from "./getCompiler";
import getErrors from "./getErrors";
import getExecutedCode from "./getExecutedCode";
import getCodeFromBundle from "./getCodeFromBundle";
import getWarnings from "./getWarnings";
import normalizeErrors from "./normalizeErrors";
import readAsset from "./readAsset";
import readsAssets from "./readAssets";
export {
compile,
execute,
getCompiler,
getErrors,
getExecutedCode,
getCodeFromBundle,
getWarnings,
normalizeErrors,
readAsset,
readsAssets,
};
postcss-loader-7.0.2/test/helpers/normalizeErrors.js 0000664 0000000 0000000 00000001346 14341464453 0022652 0 ustar 00root root 0000000 0000000 import stripAnsi from "strip-ansi";
function removeCWD(str) {
const isWin = process.platform === "win32";
let cwd = process.cwd();
if (isWin) {
// eslint-disable-next-line no-param-reassign
str = str.replace(/\\/g, "/");
// eslint-disable-next-line no-param-reassign
cwd = cwd.replace(/\\/g, "/");
}
return stripAnsi(str)
.replace(/\(from .*?\)/, "(from `replaced original path`)")
.replace(new RegExp(cwd, "g"), "");
}
export default (errors, shortError) =>
errors.map((error) => {
let errorMessage = error.toString();
if (shortError) {
errorMessage = errorMessage.split("\n").slice(0, 2).join("\n");
}
return removeCWD(errorMessage.split("\n").slice(0, 12).join("\n"));
});
postcss-loader-7.0.2/test/helpers/readAsset.js 0000664 0000000 0000000 00000001004 14341464453 0021357 0 ustar 00root root 0000000 0000000 import path from "path";
export default (asset, compiler, stats) => {
const usedFs = compiler.outputFileSystem;
const outputPath = stats.compilation.outputOptions.path;
let data = "";
let targetFile = asset;
const queryStringIdx = targetFile.indexOf("?");
if (queryStringIdx >= 0) {
targetFile = targetFile.slice(0, queryStringIdx);
}
try {
data = usedFs.readFileSync(path.join(outputPath, targetFile)).toString();
} catch (error) {
data = error.toString();
}
return data;
};
postcss-loader-7.0.2/test/helpers/readAssets.js 0000664 0000000 0000000 00000000400 14341464453 0021541 0 ustar 00root root 0000000 0000000 import readAsset from "./readAsset";
export default function readAssets(compiler, stats) {
const assets = {};
Object.keys(stats.compilation.assets).forEach((asset) => {
assets[asset] = readAsset(asset, compiler, stats);
});
return assets;
}
postcss-loader-7.0.2/test/helpers/testLoader.js 0000664 0000000 0000000 00000000331 14341464453 0021554 0 ustar 00root root 0000000 0000000 function testLoader(content, sourceMap) {
const result = { css: content };
if (sourceMap) {
result.map = sourceMap;
}
return `module.exports = ${JSON.stringify(result)}`;
}
module.exports = testLoader;
postcss-loader-7.0.2/test/implementation.test.js 0000664 0000000 0000000 00000003044 14341464453 0022013 0 ustar 00root root 0000000 0000000 import postcss from "postcss";
import {
compile,
getCompiler,
getErrors,
getCodeFromBundle,
getWarnings,
} from "./helpers";
describe('"implementation" option', () => {
it("should work with implementation is string", async () => {
const compiler = getCompiler("./css/index.js", {
implementation: require.resolve("postcss"),
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it("should throw error when unresolved package", async () => {
const compiler = getCompiler("./css/index.js", {
implementation: "unresolved",
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it("should work with a custom instance of PostCSS", async () => {
const spy = jest.fn(postcss);
const compiler = getCompiler("./css/index.js", {
// Wrap the spy so it is an instanceof Function
implementation: (...args) => spy(...args),
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(spy).toHaveBeenCalledTimes(1);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
});
postcss-loader-7.0.2/test/loader.test.js 0000664 0000000 0000000 00000022665 14341464453 0020246 0 ustar 00root root 0000000 0000000 import path from "path";
import postcss from "postcss";
// eslint-disable-next-line import/no-namespace
import * as utils from "../src/utils";
import {
compile,
getCompiler,
getErrors,
getCodeFromBundle,
getWarnings,
} from "./helpers/index";
describe("loader", () => {
it("should work", async () => {
const compiler = getCompiler("./css/index.js");
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it("should throw an error on invalid syntax", async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
hideNothingWarning: true,
parser: "sugarss",
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should emit warning using the "messages" API', async () => {
const plugin = () => (css, result) => {
css.walkDecls((node) => {
node.warn(result, "");
});
};
const postcssPlugin = postcss.plugin("postcss-plugin", plugin);
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: [postcssPlugin()],
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should emit asset using the "messages" API', async () => {
const plugin = () => (css, result) => {
result.messages.push({
type: "asset",
file: "sprite.svg",
content: "... ",
plugin,
});
};
const postcssPlugin = postcss.plugin("postcss-assets", plugin);
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: [postcssPlugin()],
},
});
const stats = await compile(compiler);
// eslint-disable-next-line no-underscore-dangle
expect(stats.compilation.assets["sprite.svg"]).toBeDefined();
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should register dependencies using the "messages" API', async () => {
const plugin = () => (css, result) => {
result.messages.push(
{
type: "build-dependency",
file: path.resolve(__dirname, "fixtures", "build-dep.html"),
content: "",
plugin,
},
{
type: "missing-dependency",
file: path.resolve(__dirname, "fixtures", "missing-dep.html"),
content: "",
plugin,
},
{
type: "context-dependency",
file: path.resolve(__dirname, "fixtures", "deps"),
content: "",
plugin,
},
{
type: "dir-dependency",
dir: path.resolve(__dirname, "fixtures", "deps2"),
content: "",
plugin,
}
);
};
const postcssPlugin = postcss.plugin("postcss-plugin", plugin);
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: [postcssPlugin()],
},
});
const stats = await compile(compiler);
const { contextDependencies, missingDependencies, buildDependencies } =
stats.compilation;
expect(contextDependencies).toContain(
path.resolve(__dirname, "fixtures", "deps")
);
expect(contextDependencies).toContain(
path.resolve(__dirname, "fixtures", "deps2")
);
expect(missingDependencies).toContain(
path.resolve(__dirname, "fixtures", "missing-dep.html")
);
expect(buildDependencies).toContain(
path.resolve(__dirname, "fixtures", "build-dep.html")
);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it("should reuse PostCSS AST", async () => {
const spy = jest.fn();
const compiler = getCompiler(
"./css/index.js",
{},
{
module: {
rules: [
{
test: /\.(css|sss)$/i,
use: [
{
loader: require.resolve("./helpers/testLoader"),
options: {},
},
{
loader: path.resolve(__dirname, "../src"),
options: {
postcssOptions: { hideNothingWarning: true },
},
},
{
loader: require.resolve("./helpers/astLoader"),
options: { spy },
},
],
},
],
},
}
);
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(spy).toHaveBeenCalledTimes(1);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it("should work with SugarSS", async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
parser: "sugarss",
hideNothingWarning: true,
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.sss", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
});
describe("check postcss versions to avoid using PostCSS 7", () => {
it("should emit a warning if postcss version is not explicitly specified when the loader is failed", async () => {
const spy = jest
.spyOn(utils, "findPackageJSONDir")
.mockReturnValue(
path.resolve(__dirname, "./fixtures/package-json-files/no-postcss")
);
const compiler = getCompiler("./css/index.js", {
implementation: (...args) => {
const result = postcss(...args);
result.version = "7.0.0";
result.process = () =>
Promise.reject(new Error("Something went wrong."));
return result;
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
spy.mockRestore();
});
it("should not show a warning if 'postcss' version is explicitly defined in 'dependencies'", async () => {
const spy = jest
.spyOn(utils, "findPackageJSONDir")
.mockReturnValue(
path.resolve(
__dirname,
"./fixtures/package-json-files/postcss-v8-in-dependencies"
)
);
const compiler = getCompiler("./css/index.js", {
implementation: (...args) => {
const result = postcss(...args);
result.version = "7.0.0";
result.process = () =>
Promise.reject(new Error("Something went wrong."));
return result;
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
spy.mockRestore();
});
it("should not show a warning if 'postcss' version is explicitly defined in 'devDependencies'", async () => {
const spy = jest
.spyOn(utils, "findPackageJSONDir")
.mockReturnValue(
path.resolve(
__dirname,
"./fixtures/package-json-files/postcss-v8-in-devDependencies"
)
);
const compiler = getCompiler("./css/index.js", {
implementation: (...args) => {
const result = postcss(...args);
result.version = "7.0.0";
result.process = () =>
Promise.reject(new Error("Something went wrong."));
return result;
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
spy.mockRestore();
});
it("should not show a warning if 'package.json' file was not found", async () => {
const spy = jest
.spyOn(utils, "findPackageJSONDir")
.mockReturnValue(
path.resolve(__dirname, "./fixtures/package-json-files/unknown")
);
const compiler = getCompiler("./css/index.js", {
implementation: (...args) => {
const result = postcss(...args);
result.version = "7.0.0";
result.process = () =>
Promise.reject(new Error("Something went wrong."));
return result;
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
spy.mockRestore();
});
it("should work when 'processor' throw an error", async () => {
const spy = jest
.spyOn(utils, "findPackageJSONDir")
.mockReturnValue(
path.resolve(__dirname, "./fixtures/package-json-files/no-postcss")
);
const compiler = getCompiler("./css/index.js", {
implementation: () => {
throw new Error("Error in implementation");
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
spy.mockRestore();
});
});
postcss-loader-7.0.2/test/postcssOptions.test.js 0000664 0000000 0000000 00000071642 14341464453 0022051 0 ustar 00root root 0000000 0000000 import path from "path";
import {
compile,
getCompiler,
getErrors,
getCodeFromBundle,
getWarnings,
} from "./helpers";
import myPostcssPlugin from "./fixtures/plugin/plugin";
jest.setTimeout(30000);
describe('"postcssOptions" option', () => {
it('should work without the specified values in the "postcssOptions" option', async () => {
const compiler = getCompiler("./config-scope/css/index.js", {
postcssOptions: {},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with "from", "to" and "map" options (absolute paths)', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
from: "/test/from.css",
to: "/test/to.css",
map: { inline: false, annotation: false },
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
const toIsWork = codeFromBundle.sourceMap.file.endsWith("to.css");
const fromIsWork =
codeFromBundle.sourceMap.sources.filter((i) => i.endsWith("from.css"))
.length > 0;
expect(toIsWork).toBe(true);
expect(fromIsWork).toBe(true);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(codeFromBundle.map).toMatchSnapshot("map");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with "from", "to" and "map" options (relative paths)', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
from: "./css/style.css",
to: "./css/style.css",
map: { inline: false, annotation: false },
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
const toIsWork = codeFromBundle.sourceMap.file.endsWith("style.css");
const fromIsWork =
codeFromBundle.sourceMap.sources.filter((i) => i.endsWith("style.css"))
.length > 0;
expect(toIsWork).toBe(true);
expect(fromIsWork).toBe(true);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(codeFromBundle.map).toMatchSnapshot("map");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "map" option and generate inlined source maps', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
map: { inline: true, annotation: false },
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(codeFromBundle.map).toMatchSnapshot("map");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work "Function" value', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: () => {
return {
// eslint-disable-next-line global-require
plugins: [require("./fixtures/config-scope/config/plugin")()],
};
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work "Function" value and with "Array" syntax of the "plugins" option', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: () => {
return {
// eslint-disable-next-line global-require
plugins: [require("./fixtures/config-scope/config/plugin")()],
};
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work "Function" value and with "Object" syntax of the "plugins" option', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: () => {
return {
// eslint-disable-next-line global-require
plugins: [require("./fixtures/config-scope/config/plugin")()],
};
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "parser" option with "String" value', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
parser: "sugarss",
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.sss", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "parser" option with "Object" value', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
// eslint-disable-next-line global-require,import/no-dynamic-require
parser: require("sugarss"),
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.sss", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
// TODO jest have not good support for ES modules for testing it, tested manually
it.skip('should work with the "parser" option with "Object" value with ESM', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
parser: path.resolve(__dirname, "../fixtures/esparser/index.mjs"),
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.sss", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
// TODO jest have not good support for ES modules for testing it, tested manually
it.skip('should work with the "stringifier" option with "Object" value with ESM', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
stringifier: path.resolve(__dirname, "../fixtures/esparser/index.mjs"),
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.sss", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
// TODO jest have not good support for ES modules for testing it, tested manually
it.skip('should work with the "syntax" option with "Object" value with ESM', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
syntax: path.resolve(__dirname, "../fixtures/esparser/index.mjs"),
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.sss", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "parser" option with "Function" value', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
// eslint-disable-next-line global-require,import/no-dynamic-require
parser: require("sugarss").parse,
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.sss", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should throw an error with the "parser" option on the unresolved parser', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
parser: "unresolved",
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats, true)).toMatchSnapshot("errors");
});
it('should work with the "stringifier" option with "String" value', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
stringifier: "sugarss",
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "stringifier" option with "Object" value', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
// eslint-disable-next-line global-require
stringifier: require("sugarss"),
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "stringifier" option with "Function" value', async () => {
// eslint-disable-next-line global-require
const Midas = require("midas");
const midas = new Midas();
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
stringifier: midas.stringifier,
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should throw an error with the "stringifier" option on the unresolved stringifier', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
stringifier: "unresolved",
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats, true)).toMatchSnapshot("errors");
});
it('should work with the "syntax" option with "String" value', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
syntax: "sugarss",
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.sss", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "syntax" option with "Object" value', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
// eslint-disable-next-line global-require
syntax: require("sugarss"),
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.sss", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should throw an error with "syntax" option on the unresolved syntax', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
syntax: "unresolved",
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(
getErrors(stats, true).map((item) =>
item
.replace("property 'parse'", "properties")
.replace(/undefined$/, "undefined (reading 'parse')")
)
).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with "Array" value', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: [
"postcss-nested",
["postcss-short", { prefix: "x" }],
myPostcssPlugin,
// Like:
// `
// import myPlugin from './path/to/plugin.mjs';
//
// const initPlugin = myPlugin();
// `
(root) => {
root.walkDecls((decl) => {
if (decl.value === "red") {
// eslint-disable-next-line no-param-reassign
decl.value = "rgba(255, 0, 0, 1.0)";
}
});
},
// Like:
// `
// import myPlugin from './path/to/plugin.mjs';
// `
{
postcss: (root) => {
root.walkDecls((decl) => {
if (decl.value === "green") {
// eslint-disable-next-line no-param-reassign
decl.value = "rgba(0, 255, 0, 1.0)";
}
});
},
},
require.resolve("./fixtures/plugin/other-plugin"),
myPostcssPlugin({ color: "white", alpha: 0 }),
{ "postcss-short": { prefix: "z" } },
// New API
require.resolve("./fixtures/plugin/new-api.plugin"),
],
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with "Object" value', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: {
"postcss-import": {},
"postcss-nested": {},
"postcss-short": { prefix: "x" },
[require.resolve("./fixtures/plugin/other-plugin")]: {},
},
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with empty "Array" value', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: [],
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with empty "Object" value', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: {},
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with "Array" value and support disabling plugins from the configuration', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
config: path.resolve(__dirname, "./fixtures/css/plugins.config.js"),
plugins: [{ "postcss-short": false }],
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with "Object" value and support disabling plugins from the configuration', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
config: path.resolve(__dirname, "./fixtures/css/plugins.config.js"),
plugins: {
"postcss-short": false,
},
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with "Object" value and only disabled plugins', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: {
"postcss-import": false,
"postcss-nested": false,
"postcss-short": false,
},
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with "Array" value and override the previous plugin options', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: [
["postcss-short", { prefix: "x" }],
["postcss-short", { prefix: "z" }],
],
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with "Object" value and override the previous plugin options', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: {
"postcss-short": { prefix: "x" },
// eslint-disable-next-line no-dupe-keys
"postcss-short": { prefix: "z" },
},
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with "Array" value, and config, and override the previous plugin options', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
config: path.resolve(__dirname, "./fixtures/css/plugins.config.js"),
plugins: [["postcss-short", { prefix: "z" }]],
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with "Object" value, and config, and override the previous plugin options', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
config: path.resolve(__dirname, "./fixtures/css/plugins.config.js"),
plugins: {
"postcss-short": { prefix: "z" },
},
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should throw an error with the "plugins" option on the unresolved plugin', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: ["postcss-unresolved"],
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats, true)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with "Array" value and not throw an error on falsy plugin', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
// eslint-disable-next-line no-undefined
plugins: [undefined, null, "", 0],
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats, true)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with the "default" property without options', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: [
path.resolve(__dirname, "./fixtures/plugin/default-other-plugin.js"),
],
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "plugins" option with the "default" property with options', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
plugins: [
[
path.resolve(
__dirname,
"./fixtures/plugin/default-other-plugin.js"
),
{ alpha: 0.5, color: "red" },
],
],
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "config" options with "false" value', async () => {
const compiler = getCompiler("./config-scope/css/index.js", {
postcssOptions: {
config: false,
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "config" options with "true" value', async () => {
const compiler = getCompiler("./config-scope/css/index.js", {
postcssOptions: {
config: true,
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "config" options with "String" value (absolute path)', async () => {
const compiler = getCompiler("./config-scope/css/index.js", {
postcssOptions: {
config: path.resolve(
__dirname,
"./fixtures/config-scope/css/custom.config.js"
),
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "config" options "String" value (relative path)', async () => {
const compiler = getCompiler("./config-scope/css/index.js", {
postcssOptions: {
config: "test/fixtures/config-scope/css/custom.config.js",
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "config" options with "String" value (with path to the directory with the configuration)', async () => {
const compiler = getCompiler("./config-scope/css/index.js", {
postcssOptions: {
config: "test/fixtures/config-scope",
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "config" options with "package.json" configuration', async () => {
const compiler = getCompiler("./config-autoload/pkg/index.js", {
postcssOptions: {
config: path.resolve(__dirname, "./fixtures", "config-autoload/pkg"),
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("index.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "config" options and use plugins', async () => {
const compiler = getCompiler("./config-scope/with-config/index.js", {
postcssOptions: {
config: true,
plugins: ["postcss-dark-theme-class"],
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should work with the "config" options with "String" value and respect all options', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
config: path.resolve(
__dirname,
"./fixtures/config-scope/all-options/postcss.config.js"
),
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.sss", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should throw an error with the "config" option on the unresolved config', async () => {
const compiler = getCompiler("./config-scope/css/index.js", {
postcssOptions: {
config: path.resolve(
__dirname,
"./fixtures/config-scope/css/unresolve.js"
),
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats, true)).toMatchSnapshot("errors");
});
it('should throw an error with the "config" option on the invalid config', async () => {
const compiler = getCompiler("./config-scope/css/index.js", {
postcssOptions: {
config: path.resolve(
__dirname,
"./fixtures/config-scope/css/invalid.config.js"
),
},
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats, true)).toMatchSnapshot("errors");
});
it('should work with the "config" options and resolve "from" and "to" options', async () => {
const compiler = getCompiler("./config-scope/css/index.js", {
postcssOptions: {
config: path.resolve(
__dirname,
"./fixtures/config-scope/from-to/postcss.config.js"
),
},
});
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
sourceMap.sourceRoot = "";
sourceMap.sources = sourceMap.sources.map((source) => {
expect(path.isAbsolute(source)).toBe(false);
expect(source).toBe(path.normalize(source));
return source.replace(/\\/g, "/");
});
expect(css).toMatchSnapshot("css");
expect(sourceMap).toMatchSnapshot("source map");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it("should work and provide API for the configuration", async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
config: path.resolve(
__dirname,
"./fixtures/config-scope/api/postcss.config.js"
),
},
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
});
postcss-loader-7.0.2/test/sourceMap.test.js 0000664 0000000 0000000 00000036022 14341464453 0020726 0 ustar 00root root 0000000 0000000 /**
* @jest-environment node
*/
import path from "path";
import fs from "fs";
import {
compile,
getCompiler,
getErrors,
getCodeFromBundle,
getWarnings,
} from "./helpers";
describe('"sourceMap" option', () => {
it('should generate source maps with "true" value and the "devtool" with "false" value', async () => {
const compiler = getCompiler(
"./css/index.js",
{
sourceMap: true,
postcssOptions: { hideNothingWarning: true },
},
{
devtool: false,
}
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
sourceMap.sourceRoot = "";
sourceMap.sources = sourceMap.sources.map((source) => {
expect(path.isAbsolute(source)).toBe(true);
expect(source).toBe(path.normalize(source));
expect(fs.existsSync(path.resolve(sourceMap.sourceRoot, source))).toBe(
true
);
return path
.relative(path.resolve(__dirname, "./fixtures"), source)
.replace(/\\/g, "/");
});
expect(css).toMatchSnapshot("css");
expect(sourceMap).toMatchSnapshot("source map");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should generate source maps with "true" value and the "devtool" option with "source-map" value', async () => {
const compiler = getCompiler(
"./css/index.js",
{
sourceMap: true,
postcssOptions: { hideNothingWarning: true },
},
{
devtool: "source-map",
}
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
sourceMap.sourceRoot = "";
sourceMap.sources = sourceMap.sources.map((source) => {
expect(path.isAbsolute(source)).toBe(true);
expect(source).toBe(path.normalize(source));
expect(fs.existsSync(path.resolve(sourceMap.sourceRoot, source))).toBe(
true
);
return path
.relative(path.resolve(__dirname, "./fixtures"), source)
.replace(/\\/g, "/");
});
expect(css).toMatchSnapshot("css");
expect(sourceMap).toMatchSnapshot("source map");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should generate source maps when value is not specified and the "devtool" with "source-map" value', async () => {
const compiler = getCompiler(
"./css/index.js",
{
postcssOptions: { hideNothingWarning: true },
},
{
devtool: "source-map",
}
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
sourceMap.sourceRoot = "";
sourceMap.sources = sourceMap.sources.map((source) => {
expect(path.isAbsolute(source)).toBe(true);
expect(source).toBe(path.normalize(source));
expect(fs.existsSync(path.resolve(sourceMap.sourceRoot, source))).toBe(
true
);
return path
.relative(path.resolve(__dirname, "./fixtures"), source)
.replace(/\\/g, "/");
});
expect(css).toMatchSnapshot("css");
expect(sourceMap).toMatchSnapshot("source map");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should generate source maps with "false" value, but the "postcssOptions.map" has values', async () => {
const compiler = getCompiler(
"./css/index.js",
{
postcssOptions: {
map: {
inline: false,
annotation: false,
prev: false,
sourcesContent: true,
},
hideNothingWarning: true,
},
},
{
devtool: false,
}
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
sourceMap.sourceRoot = "";
sourceMap.sources = sourceMap.sources.map((source) => {
expect(path.isAbsolute(source)).toBe(false);
expect(source).toBe(path.normalize(source));
expect(
fs.existsSync(path.resolve(__dirname, "./fixtures/css", source))
).toBe(true);
return source.replace(/\\/g, "/");
});
expect(css).toMatchSnapshot("css");
expect(sourceMap).toMatchSnapshot("source map");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should generate source maps using the "postcssOptions.map" option with "true" value and previous loader returns source maps ("sass-loader")', async () => {
const compiler = getCompiler(
"./scss/index.js",
{},
{
devtool: false,
module: {
rules: [
{
test: /\.scss$/i,
use: [
{
loader: require.resolve("./helpers/testLoader"),
options: {},
},
{
loader: path.resolve(__dirname, "../src"),
options: {
postcssOptions: {
map: true,
hideNothingWarning: true,
},
},
},
{
loader: "sass-loader",
options: {
// eslint-disable-next-line global-require
implementation: require("sass"),
sassOptions: {
sourceMap: true,
sourceMapRoot: path.resolve(
__dirname,
"./fixtures/scss/"
),
outFile: path.resolve(
__dirname,
"./fixtures/scss/style.css.map"
),
sourceMapContents: true,
omitSourceMapUrl: true,
sourceMapEmbed: false,
},
},
},
],
},
],
},
}
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.scss", stats);
expect(css).toMatchSnapshot("css");
expect(sourceMap).toBeUndefined();
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should generate source maps using the "postcssOptions.map" option with values and previous loader returns source maps ("sass-loader")', async () => {
const compiler = getCompiler(
"./scss/index.js",
{},
{
devtool: false,
module: {
rules: [
{
test: /\.scss$/i,
use: [
{
loader: require.resolve("./helpers/testLoader"),
options: {},
},
{
loader: path.resolve(__dirname, "../src"),
options: {
postcssOptions: {
map: {
inline: false,
sourcesContent: true,
annotation: true,
},
hideNothingWarning: true,
},
},
},
{
loader: "sass-loader",
options: {
// eslint-disable-next-line global-require
implementation: require("sass"),
sassOptions: {
sourceMap: true,
sourceMapRoot: path.resolve(
__dirname,
"./fixtures/scss/"
),
outFile: path.resolve(
__dirname,
"./fixtures/scss/style.css.map"
),
sourceMapContents: true,
omitSourceMapUrl: true,
sourceMapEmbed: false,
},
},
},
],
},
],
},
}
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.scss", stats);
sourceMap.sourceRoot = "";
sourceMap.sources = sourceMap.sources.map((source) => {
expect(path.isAbsolute(source)).toBe(false);
expect(
fs.existsSync(path.resolve(__dirname, "./fixtures/scss", source))
).toBe(true);
return source.replace(/\\/g, "/");
});
expect(css).toMatchSnapshot("css");
expect(sourceMap).toMatchSnapshot("source map");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should not generate source maps with "false" value and the "devtool" option with "false" value', async () => {
const compiler = getCompiler(
"./css/index.js",
{
sourceMap: false,
postcssOptions: { hideNothingWarning: true },
},
{
devtool: false,
}
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
expect(css).toMatchSnapshot("css");
expect(sourceMap).toBeUndefined();
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should not generate source maps with "false" value and the "devtool" option with "source-map" value', async () => {
const compiler = getCompiler(
"./css/index.js",
{
sourceMap: false,
postcssOptions: { hideNothingWarning: true },
},
{
devtool: "source-map",
}
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
expect(css).toMatchSnapshot("css");
expect(sourceMap).toBeUndefined();
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should not generate source maps when value is not specified and the "devtool" option with "source-map" value', async () => {
const compiler = getCompiler(
"./css/index.js",
{
postcssOptions: { hideNothingWarning: true },
},
{
devtool: false,
}
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
expect(css).toMatchSnapshot("css");
expect(sourceMap).toBeUndefined();
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should generate source maps when previous loader returns source maps ("sass-loader")', async () => {
const compiler = getCompiler(
"./scss/index.js",
{},
{
devtool: "source-map",
module: {
rules: [
{
test: /\.scss$/i,
use: [
{
loader: require.resolve("./helpers/testLoader"),
},
{
loader: path.resolve(__dirname, "../src"),
options: {
postcssOptions: { hideNothingWarning: true },
},
},
{
loader: "sass-loader",
options: {
// eslint-disable-next-line global-require
implementation: require("sass"),
},
},
],
},
],
},
}
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.scss", stats);
sourceMap.sourceRoot = "";
sourceMap.sources = sourceMap.sources.map((source) => {
expect(path.isAbsolute(source)).toBe(true);
expect(source).toBe(path.normalize(source));
expect(fs.existsSync(path.resolve(sourceMap.sourceRoot, source))).toBe(
true
);
return path
.relative(path.resolve(__dirname, "./fixtures"), source)
.replace(/\\/g, "/");
});
expect(css).toMatchSnapshot("css");
expect(sourceMap).toMatchSnapshot("source map");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should generate source maps when previous loader returns source maps ("less-loader")', async () => {
const compiler = getCompiler(
"./less/index.js",
{},
{
devtool: "source-map",
module: {
rules: [
{
test: /\.less$/i,
use: [
{
loader: require.resolve("./helpers/testLoader"),
options: {},
},
{
loader: path.resolve(__dirname, "../src"),
options: {
postcssOptions: { hideNothingWarning: true },
},
},
{
loader: "less-loader",
},
],
},
],
},
}
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.less", stats);
sourceMap.sourceRoot = "";
sourceMap.sources = sourceMap.sources.map((source) => {
expect(path.isAbsolute(source)).toBe(true);
expect(source).toBe(path.normalize(source));
expect(fs.existsSync(path.resolve(sourceMap.sourceRoot, source))).toBe(
true
);
return path
.relative(path.resolve(__dirname, "./fixtures"), source)
.replace(/\\/g, "/");
});
expect(css).toMatchSnapshot("css");
expect(sourceMap).toMatchSnapshot("source map");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should generate inline source maps when the "devtool" is "false"', async () => {
const compiler = getCompiler(
"./css/index.js",
{
postcssOptions: {
map: {
inline: true,
annotation: false,
},
hideNothingWarning: true,
},
},
{
devtool: false,
}
);
const stats = await compile(compiler);
const { css } = getCodeFromBundle("style.css", stats);
expect(css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it('should generate inline source maps when the "devtool" is "true"', async () => {
const compiler = getCompiler(
"./css/index.js",
{
postcssOptions: {
map: {
inline: true,
annotation: false,
},
hideNothingWarning: true,
},
},
{
devtool: "source-map",
}
);
const stats = await compile(compiler);
const { css } = getCodeFromBundle("style.css", stats);
expect(css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
});
postcss-loader-7.0.2/test/validate-options.test.js 0000664 0000000 0000000 00000007232 14341464453 0022253 0 ustar 00root root 0000000 0000000 /* eslint-disable global-require */
import path from "path";
import { getCompiler, compile } from "./helpers/index";
describe("validate options", () => {
const tests = {
execute: {
success: [false],
failure: [1, "test", /test/, [], {}, { foo: "bar" }],
},
postcssOptions: {
success: [
{ parser: "sugarss" },
{ parser: require("sugarss") },
{ parser: require("sugarss").parse },
{ syntax: "sugarss" },
{ syntax: require("sugarss") },
{ stringifier: "sugarss" },
{ stringifier: require("sugarss") },
{ stringifier: require("sugarss").stringify },
{
plugins: [
require("./fixtures/plugin/plugin")(),
require("./fixtures/plugin/plugin"),
["postcss-short", { prefix: "x" }],
],
},
{
plugins: [
require("./fixtures/plugin/plugin")(),
require("./fixtures/plugin/plugin"),
{ "postcss-short": { prefix: "x" } },
],
},
{ plugins: { "postcss-short": { prefix: "x" } } },
{ config: true },
{ config: false },
{ config: "test/fixtures/config-scope/config/postcss.config.js" },
{
config: path.resolve(
__dirname,
"./fixtures/config-scope/config/postcss.config.js"
),
},
],
failure: [{ config: [] }, { config: /test/ }],
},
sourceMap: {
success: [true, false],
failure: [1, /test/, [], {}, "something"],
},
implementation: {
success: [require("postcss"), "postcss"],
failure: [1, /test/, [], {}],
},
};
function stringifyValue(value) {
if (
Array.isArray(value) ||
(value && typeof value === "object" && value.constructor === Object)
) {
return JSON.stringify(value);
}
return value;
}
async function createTestCase(key, value, type) {
it(`should ${
type === "success" ? "successfully validate" : "throw an error on"
} the "${key}" option with "${stringifyValue(value)}" value`, async () => {
let compiler;
if (
key === "postcssOptions" &&
// eslint-disable-next-line no-prototype-builtins
(value.hasOwnProperty("parser") || value.hasOwnProperty("syntax"))
) {
compiler = getCompiler(
"./sss/index.js",
{},
{
module: {
rules: [
{
test: /\.sss$/i,
use: [
{
loader: require.resolve("./helpers/testLoader"),
options: {},
},
{
loader: path.resolve(__dirname, "../src"),
options: { [key]: value },
},
],
},
],
},
}
);
} else {
compiler = getCompiler("./css/index.js", { [key]: value });
}
let stats;
try {
stats = await compile(compiler);
} finally {
if (type === "success") {
expect(stats.hasErrors()).toBe(false);
} else if (type === "failure") {
const {
compilation: { errors },
} = stats;
expect(errors).toHaveLength(1);
expect(() => {
throw new Error(errors[0].error.message);
}).toThrowErrorMatchingSnapshot();
}
}
});
}
for (const [key, values] of Object.entries(tests)) {
for (const type of Object.keys(values)) {
for (const value of values[type]) {
createTestCase(key, value, type);
}
}
}
});