",
]
`;
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`] = `Array []`;
exports[`loader should reuse PostCSS AST: warnings 1`] = `Array []`;
exports[`loader should throw an error on invalid syntax: errors 1`] = `
Array [
"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`] = `Array []`;
exports[`loader should work with SugarSS: css 1`] = `
"a {
color: black
}
"
`;
exports[`loader should work with SugarSS: errors 1`] = `Array []`;
exports[`loader should work with SugarSS: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`loader should work: warnings 1`] = `Array []`;
postcss-loader-4.2.0/test/__snapshots__/postcssOptins.test.js.snap 0000664 0000000 0000000 00000106374 14002266724 0025441 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`] = `
Array [
"ModuleBuildError: Module build failed (from \`replaced original path\`):
TypeError: Cannot read property 'parse' of undefined",
"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`] = `Array []`;
exports[`"postcssOptions" option should throw an error with the "config" option on the invalid config: errors 1`] = `
Array [
"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`] = `Array []`;
exports[`"postcssOptions" option should throw an error with the "config" option on the unresolved config: errors 1`] = `
Array [
"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`] = `Array []`;
exports[`"postcssOptions" option should throw an error with the "parser" option on the unresolved parser: errors 1`] = `
Array [
"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`] = `Array []`;
exports[`"postcssOptions" option should throw an error with the "plugins" option on the unresolved plugin: errors 1`] = `
Array [
"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`] = `Array []`;
exports[`"postcssOptions" option should throw an error with the "stringifier" option on the unresolved stringifier: errors 1`] = `
Array [
"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`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work "Function" value and with "Array" syntax of the "plugins" option: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work "Function" value and with "Object" syntax of the "plugins" option: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work "Function" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work and provide API for the configuration: warnings 1`] = `Array []`;
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`] = `Array []`;
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`] = `Array []`;
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`] = `Array []`;
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`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "config" options "String" value (relative path): warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "config" options and resolve "from" and "to" options: source map 1`] = `
Object {
"file": "style.css",
"mappings": "AAAA,IAAI,aAAa;;AAEjB;EACE,YAAY;AACd",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"style.css",
],
"sourcesContent": Array [
"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`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "config" options and use plugins: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "config" options with "String" value (absolute path): warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "config" options with "String" value (with path to the directory with the configuration): warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "config" options with "String" value and respect all options: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "config" options with "false" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "config" options with "package.json" configuration: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "config" options with "true" value: warnings 1`] = `Array []`;
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtFQUNFLFlBQVk7QUFDZDs7QUFFQTtFQUNFLFVBQVU7QUFDWjs7QUFFQTtFQUNFLFlBQVk7QUFDZDs7QUFFQTtFQUNFLFdBQVc7QUFDYjs7QUFFQTtFQUNFLDRCQUE0QjtFQUM1QixtQkFBbUI7QUFDckI7O0FBRUE7RUFDRSw0QkFBNEI7RUFDNUIsbUJBQW1CO0FBQ3JCOztBQUVBO0VBQ0U7SUFDRSxZQUFZOztJQUVaO01BQ0UsV0FBVztJQUNiOztJQUVBO01BQ0UsWUFBWTtJQUNkO0VBQ0Y7O0VBRUE7SUFDRSxjQUFjO0VBQ2hCO0FBQ0YiLCJmaWxlIjoic3R5bGUuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiYSB7XG4gIGNvbG9yOiBibGFjaztcbn1cblxuYSB7XG4gIGNvbG9yOiByZWQ7XG59XG5cbmEge1xuICBjb2xvcjogZ3JlZW47XG59XG5cbmEge1xuICBjb2xvcjogYmx1ZTtcbn1cblxuLmNsYXNzIHtcbiAgLXgtYm9yZGVyLWNvbG9yOiBibHVlIGJsdWUgKjtcbiAgLXgtY29sb3I6ICogI2ZhZmFmYTtcbn1cblxuLmNsYXNzLWZvbyB7XG4gIC16LWJvcmRlci1jb2xvcjogYmx1ZSBibHVlICo7XG4gIC16LWNvbG9yOiAqICNmYWZhZmE7XG59XG5cbi5waG9uZSB7XG4gICZfdGl0bGUge1xuICAgIHdpZHRoOiA1MDBweDtcblxuICAgIEBtZWRpYSAobWF4LXdpZHRoOiA1MDBweCkge1xuICAgICAgd2lkdGg6IGF1dG87XG4gICAgfVxuXG4gICAgYm9keS5pc19kYXJrICYge1xuICAgICAgY29sb3I6IHdoaXRlO1xuICAgIH1cbiAgfVxuXG4gIGltZyB7XG4gICAgZGlzcGxheTogYmxvY2s7XG4gIH1cbn1cbiJdfQ== */"
`;
exports[`"postcssOptions" option should work with the "map" option and generate inlined source maps: errors 1`] = `Array []`;
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`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "parser" option with "Function" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "parser" option with "Object" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "parser" option with "String" value: warnings 1`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and not throw an error on falsy plugin: errors 1`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and not throw an error on falsy plugin: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and override the previous plugin options: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and support disabling plugins from the configuration: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value, and config, and override the previous plugin options: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and only disabled plugins: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and override the previous plugin options: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and support disabling plugins from the configuration: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value, and config, and override the previous plugin options: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with empty "Array" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with empty "Object" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with the "default" property with options: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "plugins" option with the "default" property without options: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "stringifier" option with "Function" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "stringifier" option with "Object" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "stringifier" option with "String" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "syntax" option with "Object" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work with the "syntax" option with "String" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"postcssOptions" option should work without the specified values in the "postcssOptions" option: warnings 1`] = `Array []`;
postcss-loader-4.2.0/test/__snapshots__/sourceMap.test.js.snap 0000664 0000000 0000000 00000041527 14002266724 0024502 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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtFQUNFLFlBQVk7QUFDZDs7QUFFQTtFQUNFLFVBQVU7QUFDWjs7QUFFQTtFQUNFLFlBQVk7QUFDZDs7QUFFQTtFQUNFLFdBQVc7QUFDYjs7QUFFQTtFQUNFLDRCQUE0QjtFQUM1QixtQkFBbUI7QUFDckI7O0FBRUE7RUFDRSw0QkFBNEI7RUFDNUIsbUJBQW1CO0FBQ3JCOztBQUVBO0VBQ0U7SUFDRSxZQUFZOztJQUVaO01BQ0UsV0FBVztJQUNiOztJQUVBO01BQ0UsWUFBWTtJQUNkO0VBQ0Y7O0VBRUE7SUFDRSxjQUFjO0VBQ2hCO0FBQ0YiLCJmaWxlIjoic3R5bGUuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiYSB7XG4gIGNvbG9yOiBibGFjaztcbn1cblxuYSB7XG4gIGNvbG9yOiByZWQ7XG59XG5cbmEge1xuICBjb2xvcjogZ3JlZW47XG59XG5cbmEge1xuICBjb2xvcjogYmx1ZTtcbn1cblxuLmNsYXNzIHtcbiAgLXgtYm9yZGVyLWNvbG9yOiBibHVlIGJsdWUgKjtcbiAgLXgtY29sb3I6ICogI2ZhZmFmYTtcbn1cblxuLmNsYXNzLWZvbyB7XG4gIC16LWJvcmRlci1jb2xvcjogYmx1ZSBibHVlICo7XG4gIC16LWNvbG9yOiAqICNmYWZhZmE7XG59XG5cbi5waG9uZSB7XG4gICZfdGl0bGUge1xuICAgIHdpZHRoOiA1MDBweDtcblxuICAgIEBtZWRpYSAobWF4LXdpZHRoOiA1MDBweCkge1xuICAgICAgd2lkdGg6IGF1dG87XG4gICAgfVxuXG4gICAgYm9keS5pc19kYXJrICYge1xuICAgICAgY29sb3I6IHdoaXRlO1xuICAgIH1cbiAgfVxuXG4gIGltZyB7XG4gICAgZGlzcGxheTogYmxvY2s7XG4gIH1cbn1cbiJdfQ== */"
`;
exports[`"sourceMap" option should generate inline source maps when the "devtool" is "false": errors 1`] = `Array []`;
exports[`"sourceMap" option should generate inline source maps when the "devtool" is "false": warnings 1`] = `Array []`;
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtFQUNFLFlBQVk7QUFDZDs7QUFFQTtFQUNFLFVBQVU7QUFDWjs7QUFFQTtFQUNFLFlBQVk7QUFDZDs7QUFFQTtFQUNFLFdBQVc7QUFDYjs7QUFFQTtFQUNFLDRCQUE0QjtFQUM1QixtQkFBbUI7QUFDckI7O0FBRUE7RUFDRSw0QkFBNEI7RUFDNUIsbUJBQW1CO0FBQ3JCOztBQUVBO0VBQ0U7SUFDRSxZQUFZOztJQUVaO01BQ0UsV0FBVztJQUNiOztJQUVBO01BQ0UsWUFBWTtJQUNkO0VBQ0Y7O0VBRUE7SUFDRSxjQUFjO0VBQ2hCO0FBQ0YiLCJmaWxlIjoic3R5bGUuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiYSB7XG4gIGNvbG9yOiBibGFjaztcbn1cblxuYSB7XG4gIGNvbG9yOiByZWQ7XG59XG5cbmEge1xuICBjb2xvcjogZ3JlZW47XG59XG5cbmEge1xuICBjb2xvcjogYmx1ZTtcbn1cblxuLmNsYXNzIHtcbiAgLXgtYm9yZGVyLWNvbG9yOiBibHVlIGJsdWUgKjtcbiAgLXgtY29sb3I6ICogI2ZhZmFmYTtcbn1cblxuLmNsYXNzLWZvbyB7XG4gIC16LWJvcmRlci1jb2xvcjogYmx1ZSBibHVlICo7XG4gIC16LWNvbG9yOiAqICNmYWZhZmE7XG59XG5cbi5waG9uZSB7XG4gICZfdGl0bGUge1xuICAgIHdpZHRoOiA1MDBweDtcblxuICAgIEBtZWRpYSAobWF4LXdpZHRoOiA1MDBweCkge1xuICAgICAgd2lkdGg6IGF1dG87XG4gICAgfVxuXG4gICAgYm9keS5pc19kYXJrICYge1xuICAgICAgY29sb3I6IHdoaXRlO1xuICAgIH1cbiAgfVxuXG4gIGltZyB7XG4gICAgZGlzcGxheTogYmxvY2s7XG4gIH1cbn1cbiJdfQ== */"
`;
exports[`"sourceMap" option should generate inline source maps when the "devtool" is "true": errors 1`] = `Array []`;
exports[`"sourceMap" option should generate inline source maps when the "devtool" is "true": warnings 1`] = `Array []`;
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLnNjc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7RUFBSSxZQUFBO0FBRUoiLCJmaWxlIjoic3R5bGUuc2NzcyIsInNvdXJjZXNDb250ZW50IjpbImEgeyBjb2xvcjogY29yYWwgfVxuIl19 */"
`;
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`] = `Array []`;
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`] = `Array []`;
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`] = `Array []`;
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`] = `
Object {
"file": "style.scss",
"mappings": "AAAA;EAAI,YAAA;AAEJ",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"style.scss",
],
"sourcesContent": Array [
"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`] = `Array []`;
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`] = `Array []`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("less-loader"): source map 1`] = `
Object {
"mappings": "AAAA;EAAI,YAAA;AAEJ",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"less/style.less",
],
"sourcesContent": Array [
"a { color: coral }
",
],
"version": 3,
}
`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("less-loader"): warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("sass-loader"): source map 1`] = `
Object {
"mappings": "AAAA;EAAI,YAAA;AAEJ",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"scss/style.scss",
],
"sourcesContent": Array [
"a { color: coral }
",
],
"version": 3,
}
`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("sass-loader"): warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"sourceMap" option should generate source maps when value is not specified and the "devtool" with "source-map" value: source map 1`] = `
Object {
"mappings": "AAAA;EACE,YAAY;AACd;;AAEA;EACE,UAAU;AACZ;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,4BAA4B;EAC5B,mBAAmB;AACrB;;AAEA;EACE,4BAA4B;EAC5B,mBAAmB;AACrB;;AAEA;EACE;IACE,YAAY;;IAEZ;MACE,WAAW;IACb;;IAEA;MACE,YAAY;IACd;EACF;;EAEA;IACE,cAAc;EAChB;AACF",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"css/style.css",
],
"sourcesContent": Array [
"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`] = `Array []`;
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`] = `Array []`;
exports[`"sourceMap" option should generate source maps with "false" value, but the "postcssOptions.map" has values: source map 1`] = `
Object {
"file": "style.css",
"mappings": "AAAA;EACE,YAAY;AACd;;AAEA;EACE,UAAU;AACZ;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,4BAA4B;EAC5B,mBAAmB;AACrB;;AAEA;EACE,4BAA4B;EAC5B,mBAAmB;AACrB;;AAEA;EACE;IACE,YAAY;;IAEZ;MACE,WAAW;IACb;;IAEA;MACE,YAAY;IACd;EACF;;EAEA;IACE,cAAc;EAChB;AACF",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"style.css",
],
"sourcesContent": Array [
"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`] = `Array []`;
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`] = `Array []`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" option with "source-map" value: source map 1`] = `
Object {
"mappings": "AAAA;EACE,YAAY;AACd;;AAEA;EACE,UAAU;AACZ;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,4BAA4B;EAC5B,mBAAmB;AACrB;;AAEA;EACE,4BAA4B;EAC5B,mBAAmB;AACrB;;AAEA;EACE;IACE,YAAY;;IAEZ;MACE,WAAW;IACb;;IAEA;MACE,YAAY;IACd;EACF;;EAEA;IACE,cAAc;EAChB;AACF",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"css/style.css",
],
"sourcesContent": Array [
"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`] = `Array []`;
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`] = `Array []`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" with "false" value: source map 1`] = `
Object {
"mappings": "AAAA;EACE,YAAY;AACd;;AAEA;EACE,UAAU;AACZ;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,4BAA4B;EAC5B,mBAAmB;AACrB;;AAEA;EACE,4BAA4B;EAC5B,mBAAmB;AACrB;;AAEA;EACE;IACE,YAAY;;IAEZ;MACE,WAAW;IACb;;IAEA;MACE,YAAY;IACd;EACF;;EAEA;IACE,cAAc;EAChB;AACF",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"css/style.css",
],
"sourcesContent": Array [
"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`] = `Array []`;
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`] = `Array []`;
exports[`"sourceMap" option should not generate source maps when value is not specified and the "devtool" option with "source-map" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "false" value: warnings 1`] = `Array []`;
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`] = `Array []`;
exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "source-map" value: warnings 1`] = `Array []`;
postcss-loader-4.2.0/test/__snapshots__/validate-options.test.js.snap 0000664 0000000 0000000 00000017444 14002266724 0026027 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' (https://github.com/postcss/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' (https://github.com/postcss/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' (https://github.com/postcss/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' (https://github.com/postcss/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' (https://github.com/postcss/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' (https://github.com/postcss/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 an instance of function.
-> The implementation of postcss to use, instead of the locally installed version (https://github.com/postcss/postcss-loader#implementation)"
`;
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 an instance of function.
-> The implementation of postcss to use, instead of the locally installed version (https://github.com/postcss/postcss-loader#implementation)"
`;
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 an instance of function.
-> The implementation of postcss to use, instead of the locally installed version (https://github.com/postcss/postcss-loader#implementation)"
`;
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 an instance of function.
-> The implementation of postcss to use, instead of the locally installed version (https://github.com/postcss/postcss-loader#implementation)"
`;
exports[`validate options should throw an error on the "implementation" 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.implementation should be an instance of function.
-> The implementation of postcss to use, instead of the locally installed version (https://github.com/postcss/postcss-loader#implementation)"
`;
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\`.
Details:
* options.postcssOptions.config should be one of these:
string | boolean
-> Allows to specify PostCSS Config Path (https://github.com/postcss/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\`.
Details:
* options.postcssOptions.config should be one of these:
string | boolean
-> Allows to specify PostCSS Config Path (https://github.com/postcss/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 (https://github.com/postcss/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 (https://github.com/postcss/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 (https://github.com/postcss/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 (https://github.com/postcss/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 (https://github.com/postcss/postcss-loader#sourcemap)"
`;
postcss-loader-4.2.0/test/cjs.test.js 0000664 0000000 0000000 00000000231 14002266724 0017530 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-4.2.0/test/config-autoload.test.js 0000664 0000000 0000000 00000007664 14002266724 0022045 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,
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-4.2.0/test/execute.test.js 0000664 0000000 0000000 00000006351 14002266724 0020424 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-4.2.0/test/fixtures/ 0000775 0000000 0000000 00000000000 14002266724 0017312 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/ 0000775 0000000 0000000 00000000000 14002266724 0022365 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/empty/ 0000775 0000000 0000000 00000000000 14002266724 0023523 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/empty/.postcssrc 0000664 0000000 0000000 00000000001 14002266724 0025536 0 ustar 00root root 0000000 0000000
postcss-loader-4.2.0/test/fixtures/config-autoload/empty/expect/ 0000775 0000000 0000000 00000000000 14002266724 0025013 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/empty/expect/index.css 0000664 0000000 0000000 00000000064 14002266724 0026634 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
.test {
color: blue;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/empty/expect/index.sss 0000664 0000000 0000000 00000000062 14002266724 0026652 0 ustar 00root root 0000000 0000000 .import {
color: red
}
.test {
color: blue
}
postcss-loader-4.2.0/test/fixtures/config-autoload/empty/fixtures/ 0000775 0000000 0000000 00000000000 14002266724 0025374 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/empty/fixtures/imports/ 0000775 0000000 0000000 00000000000 14002266724 0027071 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/empty/fixtures/imports/section.css 0000664 0000000 0000000 00000000032 14002266724 0031242 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/empty/fixtures/imports/section.sss 0000664 0000000 0000000 00000000025 14002266724 0031264 0 ustar 00root root 0000000 0000000 .import
color: red
postcss-loader-4.2.0/test/fixtures/config-autoload/empty/fixtures/index.css 0000664 0000000 0000000 00000000071 14002266724 0027213 0 ustar 00root root 0000000 0000000 @import "imports/section.css";
.test {
color: blue;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/empty/fixtures/index.sss 0000664 0000000 0000000 00000000063 14002266724 0027234 0 ustar 00root root 0000000 0000000 @import "imports/section.sss"
.test
color: blue
postcss-loader-4.2.0/test/fixtures/config-autoload/err/ 0000775 0000000 0000000 00000000000 14002266724 0023155 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/err/options/ 0000775 0000000 0000000 00000000000 14002266724 0024650 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/err/options/parser/ 0000775 0000000 0000000 00000000000 14002266724 0026144 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/err/options/parser/.postcssrc.js 0000664 0000000 0000000 00000000116 14002266724 0030601 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
parser: 'postcss-parser'
}
};
postcss-loader-4.2.0/test/fixtures/config-autoload/err/options/stringifier/ 0000775 0000000 0000000 00000000000 14002266724 0027175 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/err/options/stringifier/.postcssrc.js 0000664 0000000 0000000 00000000130 14002266724 0031626 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
stringifier: 'postcss-stringifier'
}
};
postcss-loader-4.2.0/test/fixtures/config-autoload/err/options/syntax/ 0000775 0000000 0000000 00000000000 14002266724 0026176 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/err/options/syntax/.postcssrc.js 0000664 0000000 0000000 00000000116 14002266724 0030633 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
syntax: 'postcss-syntax'
}
};
postcss-loader-4.2.0/test/fixtures/config-autoload/err/plugins/ 0000775 0000000 0000000 00000000000 14002266724 0024636 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/err/plugins/.postcssrc.js 0000664 0000000 0000000 00000000140 14002266724 0027270 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
plugins: [
require('./plugin')
]
}
};
postcss-loader-4.2.0/test/fixtures/config-autoload/err/plugins/array/ 0000775 0000000 0000000 00000000000 14002266724 0025754 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/err/plugins/array/.postcssrc.js 0000664 0000000 0000000 00000000146 14002266724 0030414 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
plugins: [
require('postcss-plugin')
]
}
};
postcss-loader-4.2.0/test/fixtures/config-autoload/err/plugins/array/options/ 0000775 0000000 0000000 00000000000 14002266724 0027447 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/err/plugins/array/options/.postcssrc.js 0000664 0000000 0000000 00000000146 14002266724 0032107 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
plugins: [
require('postcss-plugin')
]
}
};
postcss-loader-4.2.0/test/fixtures/config-autoload/err/plugins/object/ 0000775 0000000 0000000 00000000000 14002266724 0026104 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/err/plugins/object/.postcssrc.js 0000664 0000000 0000000 00000000141 14002266724 0030537 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
plugins: {
'postcss-plugin': {}
}
}
};
postcss-loader-4.2.0/test/fixtures/config-autoload/err/plugins/object/options/ 0000775 0000000 0000000 00000000000 14002266724 0027577 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/err/plugins/object/options/.postcssrc.js 0000664 0000000 0000000 00000000157 14002266724 0032241 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
plugins: {
'postcss-plugin': { option: true }
}
}
};
postcss-loader-4.2.0/test/fixtures/config-autoload/err/plugins/plugin.js 0000664 0000000 0000000 00000000043 14002266724 0026467 0 ustar 00root root 0000000 0000000 module.exports = 'Invalid Plugin';
postcss-loader-4.2.0/test/fixtures/config-autoload/js/ 0000775 0000000 0000000 00000000000 14002266724 0023001 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/js/array/ 0000775 0000000 0000000 00000000000 14002266724 0024117 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/js/array/imports/ 0000775 0000000 0000000 00000000000 14002266724 0025614 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/js/array/imports/section.css 0000664 0000000 0000000 00000000040 14002266724 0027764 0 ustar 00root root 0000000 0000000 .import {
color: goldenrod;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/js/array/index.css 0000664 0000000 0000000 00000000071 14002266724 0025736 0 ustar 00root root 0000000 0000000 @import 'imports/section.css';
.test {
color: cyan;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/js/array/index.js 0000664 0000000 0000000 00000000066 14002266724 0025566 0 ustar 00root root 0000000 0000000 import style from './index.css'
export default style
postcss-loader-4.2.0/test/fixtures/config-autoload/js/array/postcss.config.js 0000664 0000000 0000000 00000000767 14002266724 0027431 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-4.2.0/test/fixtures/config-autoload/js/object/ 0000775 0000000 0000000 00000000000 14002266724 0024247 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/js/object/imports/ 0000775 0000000 0000000 00000000000 14002266724 0025744 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/js/object/imports/section.css 0000664 0000000 0000000 00000000032 14002266724 0030115 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/js/object/index.css 0000664 0000000 0000000 00000000071 14002266724 0026066 0 ustar 00root root 0000000 0000000 @import "imports/section.css";
.test {
color: blue;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/js/object/index.js 0000664 0000000 0000000 00000000066 14002266724 0025716 0 ustar 00root root 0000000 0000000 import style from './index.css'
export default style
postcss-loader-4.2.0/test/fixtures/config-autoload/js/object/postcss.config.js 0000664 0000000 0000000 00000000556 14002266724 0027555 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-4.2.0/test/fixtures/config-autoload/pkg/ 0000775 0000000 0000000 00000000000 14002266724 0023146 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/pkg/imports/ 0000775 0000000 0000000 00000000000 14002266724 0024643 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/pkg/imports/section.css 0000664 0000000 0000000 00000000032 14002266724 0027014 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/pkg/index.css 0000664 0000000 0000000 00000000071 14002266724 0024765 0 ustar 00root root 0000000 0000000 @import "imports/section.css";
.test {
color: blue;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/pkg/index.js 0000664 0000000 0000000 00000000066 14002266724 0024615 0 ustar 00root root 0000000 0000000 import style from './index.css'
export default style
postcss-loader-4.2.0/test/fixtures/config-autoload/pkg/package.json 0000664 0000000 0000000 00000000405 14002266724 0025433 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-4.2.0/test/fixtures/config-autoload/rc-js/ 0000775 0000000 0000000 00000000000 14002266724 0023403 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/rc-js/.postcssrc.js 0000664 0000000 0000000 00000000356 14002266724 0026046 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-4.2.0/test/fixtures/config-autoload/rc-js/expect/ 0000775 0000000 0000000 00000000000 14002266724 0024673 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/rc-js/expect/index.css 0000664 0000000 0000000 00000000064 14002266724 0026514 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
.test {
color: blue;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/rc-js/expect/index.sss 0000664 0000000 0000000 00000000062 14002266724 0026532 0 ustar 00root root 0000000 0000000 .import {
color: red
}
.test {
color: blue
}
postcss-loader-4.2.0/test/fixtures/config-autoload/rc-js/fixtures/ 0000775 0000000 0000000 00000000000 14002266724 0025254 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/rc-js/fixtures/imports/ 0000775 0000000 0000000 00000000000 14002266724 0026751 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/rc-js/fixtures/imports/section.css 0000664 0000000 0000000 00000000032 14002266724 0031122 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/rc-js/fixtures/imports/section.sss 0000664 0000000 0000000 00000000025 14002266724 0031144 0 ustar 00root root 0000000 0000000 .import
color: red
postcss-loader-4.2.0/test/fixtures/config-autoload/rc-js/fixtures/index.css 0000664 0000000 0000000 00000000071 14002266724 0027073 0 ustar 00root root 0000000 0000000 @import "imports/section.css";
.test {
color: blue;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/rc-js/fixtures/index.sss 0000664 0000000 0000000 00000000063 14002266724 0027114 0 ustar 00root root 0000000 0000000 @import "imports/section.sss"
.test
color: blue
postcss-loader-4.2.0/test/fixtures/config-autoload/rc/ 0000775 0000000 0000000 00000000000 14002266724 0022771 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/rc/.postcssrc 0000664 0000000 0000000 00000000326 14002266724 0025016 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-4.2.0/test/fixtures/config-autoload/rc/expect/ 0000775 0000000 0000000 00000000000 14002266724 0024261 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/rc/expect/index.css 0000664 0000000 0000000 00000000064 14002266724 0026102 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
.test {
color: blue;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/rc/expect/index.sss 0000664 0000000 0000000 00000000062 14002266724 0026120 0 ustar 00root root 0000000 0000000 .import {
color: red
}
.test {
color: blue
}
postcss-loader-4.2.0/test/fixtures/config-autoload/rc/fixtures/ 0000775 0000000 0000000 00000000000 14002266724 0024642 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/rc/fixtures/imports/ 0000775 0000000 0000000 00000000000 14002266724 0026337 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-autoload/rc/fixtures/imports/section.css 0000664 0000000 0000000 00000000032 14002266724 0030510 0 ustar 00root root 0000000 0000000 .import {
color: red;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/rc/fixtures/imports/section.sss 0000664 0000000 0000000 00000000025 14002266724 0030532 0 ustar 00root root 0000000 0000000 .import
color: red
postcss-loader-4.2.0/test/fixtures/config-autoload/rc/fixtures/index.css 0000664 0000000 0000000 00000000071 14002266724 0026461 0 ustar 00root root 0000000 0000000 @import "imports/section.css";
.test {
color: blue;
}
postcss-loader-4.2.0/test/fixtures/config-autoload/rc/fixtures/index.sss 0000664 0000000 0000000 00000000063 14002266724 0026502 0 ustar 00root root 0000000 0000000 @import "imports/section.sss"
.test
color: blue
postcss-loader-4.2.0/test/fixtures/config-scope/ 0000775 0000000 0000000 00000000000 14002266724 0021666 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-scope/all-options/ 0000775 0000000 0000000 00000000000 14002266724 0024127 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-scope/all-options/postcss.config.js 0000664 0000000 0000000 00000000456 14002266724 0027434 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-4.2.0/test/fixtures/config-scope/api/ 0000775 0000000 0000000 00000000000 14002266724 0022437 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-scope/api/postcss.config.js 0000664 0000000 0000000 00000001004 14002266724 0025732 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-4.2.0/test/fixtures/config-scope/config/ 0000775 0000000 0000000 00000000000 14002266724 0023133 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-scope/config/context/ 0000775 0000000 0000000 00000000000 14002266724 0024617 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-scope/config/context/plugin.js 0000664 0000000 0000000 00000000427 14002266724 0026456 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-4.2.0/test/fixtures/config-scope/config/context/postcss.config.js 0000664 0000000 0000000 00000000117 14002266724 0030116 0 ustar 00root root 0000000 0000000 module.exports = (ctx) => ({
plugins: [
require('./plugin')(ctx)
]
});
postcss-loader-4.2.0/test/fixtures/config-scope/config/plugin.js 0000664 0000000 0000000 00000000525 14002266724 0024771 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-4.2.0/test/fixtures/config-scope/config/postcss.config.js 0000664 0000000 0000000 00000000111 14002266724 0026424 0 ustar 00root root 0000000 0000000 module.exports = () => ({
plugins: [
require('./plugin')()
]
});
postcss-loader-4.2.0/test/fixtures/config-scope/css/ 0000775 0000000 0000000 00000000000 14002266724 0022456 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-scope/css/custom.config.js 0000664 0000000 0000000 00000000112 14002266724 0025564 0 ustar 00root root 0000000 0000000 module.exports = {
plugins: [
require('../config/plugin')()
]
};
postcss-loader-4.2.0/test/fixtures/config-scope/css/index.js 0000664 0000000 0000000 00000000066 14002266724 0024125 0 ustar 00root root 0000000 0000000 import style from './style.css'
export default style
postcss-loader-4.2.0/test/fixtures/config-scope/css/index2.js 0000664 0000000 0000000 00000000067 14002266724 0024210 0 ustar 00root root 0000000 0000000 import style from './style2.css'
export default style
postcss-loader-4.2.0/test/fixtures/config-scope/css/invalid.config.js 0000664 0000000 0000000 00000000053 14002266724 0025704 0 ustar 00root root 0000000 0000000 throw new Error('invalid postcss config');
postcss-loader-4.2.0/test/fixtures/config-scope/css/plugins.config.js 0000664 0000000 0000000 00000000201 14002266724 0025732 0 ustar 00root root 0000000 0000000 module.exports = {
plugins: {
'postcss-short': { prefix: 'x' },
'postcss-import': {},
'postcss-nested': {},
}
};
postcss-loader-4.2.0/test/fixtures/config-scope/css/style.css 0000664 0000000 0000000 00000000055 14002266724 0024330 0 ustar 00root root 0000000 0000000 a { color: black }
.foo {
float: right;
}
postcss-loader-4.2.0/test/fixtures/config-scope/css/style2.css 0000664 0000000 0000000 00000000075 14002266724 0024414 0 ustar 00root root 0000000 0000000 a {
-x-border-color: blue blue *;
-x-color: * #fafafa;
}
postcss-loader-4.2.0/test/fixtures/config-scope/from-to/ 0000775 0000000 0000000 00000000000 14002266724 0023251 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-scope/from-to/postcss.config.js 0000664 0000000 0000000 00000000334 14002266724 0026551 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-4.2.0/test/fixtures/config-scope/postcss.config.js 0000664 0000000 0000000 00000000111 14002266724 0025157 0 ustar 00root root 0000000 0000000 module.exports = {
plugins: [
require('./config/plugin')()
]
};
postcss-loader-4.2.0/test/fixtures/config-scope/with-config/ 0000775 0000000 0000000 00000000000 14002266724 0024104 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/config-scope/with-config/index.js 0000664 0000000 0000000 00000000066 14002266724 0025553 0 ustar 00root root 0000000 0000000 import style from './style.css'
export default style
postcss-loader-4.2.0/test/fixtures/config-scope/with-config/postcss.config.js 0000664 0000000 0000000 00000000144 14002266724 0027403 0 ustar 00root root 0000000 0000000 module.exports = function () {
return {
plugins: [['postcss-short', { prefix: 'x' }]],
}
};
postcss-loader-4.2.0/test/fixtures/config-scope/with-config/style.css 0000664 0000000 0000000 00000000410 14002266724 0025751 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-4.2.0/test/fixtures/css/ 0000775 0000000 0000000 00000000000 14002266724 0020102 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/css/index.js 0000664 0000000 0000000 00000000070 14002266724 0021544 0 ustar 00root root 0000000 0000000 import style from './style.css';
export default style;
postcss-loader-4.2.0/test/fixtures/css/plugins.config.js 0000664 0000000 0000000 00000000115 14002266724 0023362 0 ustar 00root root 0000000 0000000 module.exports = {
plugins: {
'postcss-short': { prefix: 'x' },
}
};
postcss-loader-4.2.0/test/fixtures/css/style.css 0000664 0000000 0000000 00000000633 14002266724 0021756 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-4.2.0/test/fixtures/jss/ 0000775 0000000 0000000 00000000000 14002266724 0020111 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/jss/exec/ 0000775 0000000 0000000 00000000000 14002266724 0021035 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/jss/exec/index.js 0000664 0000000 0000000 00000000074 14002266724 0022503 0 ustar 00root root 0000000 0000000 import style from './style.exec.js';
export default style;
postcss-loader-4.2.0/test/fixtures/jss/exec/style.exec.js 0000664 0000000 0000000 00000000224 14002266724 0023454 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-4.2.0/test/fixtures/jss/postcss-js/ 0000775 0000000 0000000 00000000000 14002266724 0022221 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/jss/postcss-js/index.js 0000664 0000000 0000000 00000000065 14002266724 0023667 0 ustar 00root root 0000000 0000000 import style from './style.js'
export default style
postcss-loader-4.2.0/test/fixtures/jss/postcss-js/style.js 0000664 0000000 0000000 00000000054 14002266724 0023716 0 ustar 00root root 0000000 0000000 module.exports = { a: { color: 'yellow' } }
postcss-loader-4.2.0/test/fixtures/less/ 0000775 0000000 0000000 00000000000 14002266724 0020260 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/less/index.js 0000664 0000000 0000000 00000000067 14002266724 0021730 0 ustar 00root root 0000000 0000000 import style from './style.less'
export default style
postcss-loader-4.2.0/test/fixtures/less/style.less 0000664 0000000 0000000 00000000023 14002266724 0022303 0 ustar 00root root 0000000 0000000 a { color: coral }
postcss-loader-4.2.0/test/fixtures/plugin/ 0000775 0000000 0000000 00000000000 14002266724 0020610 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/plugin/default-other-plugin.js 0000664 0000000 0000000 00000000607 14002266724 0025210 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-4.2.0/test/fixtures/plugin/new-api.plugin.js 0000664 0000000 0000000 00000000333 14002266724 0024002 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-4.2.0/test/fixtures/plugin/other-plugin.js 0000664 0000000 0000000 00000000533 14002266724 0023564 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-4.2.0/test/fixtures/plugin/plugin.js 0000664 0000000 0000000 00000000565 14002266724 0022452 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-4.2.0/test/fixtures/scss/ 0000775 0000000 0000000 00000000000 14002266724 0020265 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/scss/index.js 0000664 0000000 0000000 00000000067 14002266724 0021735 0 ustar 00root root 0000000 0000000 import style from './style.scss'
export default style
postcss-loader-4.2.0/test/fixtures/scss/style.scss 0000664 0000000 0000000 00000000023 14002266724 0022315 0 ustar 00root root 0000000 0000000 a { color: coral }
postcss-loader-4.2.0/test/fixtures/sss/ 0000775 0000000 0000000 00000000000 14002266724 0020122 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/fixtures/sss/index.js 0000664 0000000 0000000 00000000066 14002266724 0021571 0 ustar 00root root 0000000 0000000 import style from './style.sss'
export default style
postcss-loader-4.2.0/test/fixtures/sss/style.sss 0000664 0000000 0000000 00000000021 14002266724 0022005 0 ustar 00root root 0000000 0000000 a
color: black
postcss-loader-4.2.0/test/helpers/ 0000775 0000000 0000000 00000000000 14002266724 0017103 5 ustar 00root root 0000000 0000000 postcss-loader-4.2.0/test/helpers/astLoader.js 0000664 0000000 0000000 00000002061 14002266724 0021356 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-4.2.0/test/helpers/compile.js 0000664 0000000 0000000 00000000314 14002266724 0021067 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-4.2.0/test/helpers/execute.js 0000664 0000000 0000000 00000001037 14002266724 0021104 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-4.2.0/test/helpers/getCodeFromBundle.js 0000664 0000000 0000000 00000000763 14002266724 0022777 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-4.2.0/test/helpers/getCompiler.js 0000664 0000000 0000000 00000002412 14002266724 0021712 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-4.2.0/test/helpers/getErrors.js 0000664 0000000 0000000 00000000230 14002266724 0021410 0 ustar 00root root 0000000 0000000 import normalizeErrors from "./normalizeErrors";
export default (stats, shortError) =>
normalizeErrors(stats.compilation.errors, shortError).sort();
postcss-loader-4.2.0/test/helpers/getExecutedCode.js 0000664 0000000 0000000 00000000670 14002266724 0022505 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-4.2.0/test/helpers/getWarnings.js 0000664 0000000 0000000 00000000200 14002266724 0021721 0 ustar 00root root 0000000 0000000 import normalizeErrors from "./normalizeErrors";
export default (stats) => normalizeErrors(stats.compilation.warnings).sort();
postcss-loader-4.2.0/test/helpers/index.js 0000664 0000000 0000000 00000001102 14002266724 0020542 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-4.2.0/test/helpers/normalizeErrors.js 0000664 0000000 0000000 00000001346 14002266724 0022642 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-4.2.0/test/helpers/readAsset.js 0000664 0000000 0000000 00000001005 14002266724 0021350 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.substr(0, queryStringIdx);
}
try {
data = usedFs.readFileSync(path.join(outputPath, targetFile)).toString();
} catch (error) {
data = error.toString();
}
return data;
};
postcss-loader-4.2.0/test/helpers/readAssets.js 0000664 0000000 0000000 00000000400 14002266724 0021531 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-4.2.0/test/helpers/testLoader.js 0000664 0000000 0000000 00000000331 14002266724 0021544 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-4.2.0/test/implementation.test.js 0000664 0000000 0000000 00000001414 14002266724 0022002 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 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-4.2.0/test/loader.test.js 0000664 0000000 0000000 00000007673 14002266724 0020240 0 ustar 00root root 0000000 0000000 import path from "path";
import postcss from "postcss";
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 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");
});
});
postcss-loader-4.2.0/test/postcssOptins.test.js 0000664 0000000 0000000 00000065603 14002266724 0021662 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");
});
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)).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-4.2.0/test/sourceMap.test.js 0000664 0000000 0000000 00000036022 14002266724 0020716 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-4.2.0/test/validate-options.test.js 0000664 0000000 0000000 00000007234 14002266724 0022245 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")],
failure: [1, /test/, [], {}, "something"],
},
};
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);
}
}
}
});