diff --git a/test/__snapshots__/import-option.test.js.snap b/test/__snapshots__/import-option.test.js.snap index 537ebded..10945f03 100644 --- a/test/__snapshots__/import-option.test.js.snap +++ b/test/__snapshots__/import-option.test.js.snap @@ -217,21 +217,21 @@ Array [ exports[`import option true: module 1`] = ` "exports = module.exports = require(\\"../../../lib/runtime/api.js\\")(false); // imports -exports.i(require(\\"-!../../../index.js??ref--4!./test.css\\"), \\"\\"); -exports.i(require(\\"-!../../../index.js??ref--4!./test.css\\"), \\"screen and print\\"); -exports.i(require(\\"-!../../../index.js??ref--4!./test.css\\"), \\"SCREEN AND PRINT\\"); -exports.i(require(\\"-!../../../index.js??ref--4!./test.css\\"), \\"screen and print\\"); -exports.i(require(\\"-!../../../index.js??ref--4!./test-media.css\\"), \\"screen and print\\"); -exports.i(require(\\"-!../../../index.js??ref--4!./test-other.css\\"), \\"(min-width: 100px)\\"); +exports.i(require(\\"-!../../../index.js??ref--4-0!./test.css\\"), \\"\\"); +exports.i(require(\\"-!../../../index.js??ref--4-0!./test.css\\"), \\"screen and print\\"); +exports.i(require(\\"-!../../../index.js??ref--4-0!./test.css\\"), \\"SCREEN AND PRINT\\"); +exports.i(require(\\"-!../../../index.js??ref--4-0!./test.css\\"), \\"screen and print\\"); +exports.i(require(\\"-!../../../index.js??ref--4-0!./test-media.css\\"), \\"screen and print\\"); +exports.i(require(\\"-!../../../index.js??ref--4-0!./test-other.css\\"), \\"(min-width: 100px)\\"); exports.push([module.id, \\"@import url(http://example.com/style.css);\\", \\"\\"]); exports.push([module.id, \\"@import url(http://example.com/style.css#hash);\\", \\"\\"]); exports.push([module.id, \\"@import url(http://example.com/style.css?#hash);\\", \\"\\"]); exports.push([module.id, \\"@import url(http://example.com/style.css?foo=bar#hash);\\", \\"\\"]); exports.push([module.id, \\"@import url(http://example.com/other-style.css);\\", \\"screen and print\\"]); exports.push([module.id, \\"@import url(//example.com/style.css);\\", \\"\\"]); -exports.i(require(\\"-!../../../index.js??ref--4!package/test.css\\"), \\"\\"); -exports.i(require(\\"-!../../../index.js??ref--4!./query.css?foo=1&bar=1\\"), \\"\\"); -exports.i(require(\\"-!../../../index.js??ref--4!./other-query.css?foo=1&bar=1#hash\\"), \\"\\"); +exports.i(require(\\"-!../../../index.js??ref--4-0!package/test.css\\"), \\"\\"); +exports.i(require(\\"-!../../../index.js??ref--4-0!./query.css?foo=1&bar=1\\"), \\"\\"); +exports.i(require(\\"-!../../../index.js??ref--4-0!./other-query.css?foo=1&bar=1#hash\\"), \\"\\"); // module exports.push([module.id, \\"@import URL(test.css);\\\\n@import url();\\\\n@import url('');\\\\n@import url(\\\\\\"\\\\\\");\\\\n@import '';\\\\n@import \\\\\\"\\\\\\";\\\\n@import \\\\\\" \\\\\\";\\\\n@import \\\\\\"\\\\n\\\\\\";\\\\n@import url();\\\\n@import url('');\\\\n@import url(\\\\\\"\\\\\\");\\\\n@import ;\\\\n@import foo-bar;\\\\n@import-normalize;\\\\n@import url('http://') :root {}\\\\n\\\\n.class {\\\\n a: b c d;\\\\n}\\\\n\\\\n.foo {\\\\n @import 'path.css';\\\\n}\\\\n\\", \\"\\"]); diff --git a/test/__snapshots__/loader.test.js.snap b/test/__snapshots__/loader.test.js.snap index 6bb6aba0..9f8ee7e7 100644 --- a/test/__snapshots__/loader.test.js.snap +++ b/test/__snapshots__/loader.test.js.snap @@ -171,7 +171,7 @@ exports[`loader should compile with \`css\` entry point: module 1`] = ` "var escape = require(\\"../../lib/runtime/escape.js\\"); exports = module.exports = require(\\"../../lib/runtime/api.js\\")(false); // imports -exports.i(require(\\"-!../../index.js??ref--4!./imported.css\\"), \\"\\"); +exports.i(require(\\"-!../../index.js??ref--4-0!./imported.css\\"), \\"\\"); // module exports.push([module.id, \\"@charset \\\\\\"UTF-8\\\\\\";\\\\n\\\\n/* Comment */\\\\n\\\\n.class {\\\\n color: red;\\\\n background: url(\\" + escape(require(\\"./url/img.png\\")) + \\");\\\\n}\\\\n\\\\n.class-duplicate-url {\\\\n background: url(\\" + escape(require(\\"./url/img.png\\")) + \\");\\\\n}\\\\n\\\\n:root {\\\\n --foo: 1px;\\\\n --bar: 2px;\\\\n}\\\\n\\\\n.class { a: b c d; }\\\\n\\\\n.two {}\\\\n\\\\n.u-m\\\\\\\\+ { a: b c d; }\\\\n\\\\n.class { content: \\\\\\"\\\\\\\\F10C\\\\\\" }\\\\n\\\\n@media only screen and (max-width: 600px) {\\\\n body {\\\\n background-color: lightblue;\\\\n }\\\\n}\\\\n\\\\n/*\\\\nNeed uncomment after resolve https://github.com/css-modules/postcss-modules-local-by-default/issues/108\\\\n\\\\n.class {\\\\n content: \\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\f10C\\\\\\\\\\\\\\"\\\\n}\\\\n\\\\n.class {\\\\n content: \\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\F10C \\\\\\\\\\\\\\\\F10D\\\\\\\\\\\\\\"\\\\n}\\\\n*/\\\\n\\", \\"\\"]); @@ -353,7 +353,7 @@ exports[`loader should compile with \`js\` entry point: module 1`] = ` "var escape = require(\\"../../lib/runtime/escape.js\\"); exports = module.exports = require(\\"../../lib/runtime/api.js\\")(false); // imports -exports.i(require(\\"-!../../index.js??ref--4!./imported.css\\"), \\"\\"); +exports.i(require(\\"-!../../index.js??ref--4-0!./imported.css\\"), \\"\\"); // module exports.push([module.id, \\"@charset \\\\\\"UTF-8\\\\\\";\\\\n\\\\n/* Comment */\\\\n\\\\n.class {\\\\n color: red;\\\\n background: url(\\" + escape(require(\\"./url/img.png\\")) + \\");\\\\n}\\\\n\\\\n.class-duplicate-url {\\\\n background: url(\\" + escape(require(\\"./url/img.png\\")) + \\");\\\\n}\\\\n\\\\n:root {\\\\n --foo: 1px;\\\\n --bar: 2px;\\\\n}\\\\n\\\\n.class { a: b c d; }\\\\n\\\\n.two {}\\\\n\\\\n.u-m\\\\\\\\+ { a: b c d; }\\\\n\\\\n.class { content: \\\\\\"\\\\\\\\F10C\\\\\\" }\\\\n\\\\n@media only screen and (max-width: 600px) {\\\\n body {\\\\n background-color: lightblue;\\\\n }\\\\n}\\\\n\\\\n/*\\\\nNeed uncomment after resolve https://github.com/css-modules/postcss-modules-local-by-default/issues/108\\\\n\\\\n.class {\\\\n content: \\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\f10C\\\\\\\\\\\\\\"\\\\n}\\\\n\\\\n.class {\\\\n content: \\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\F10C \\\\\\\\\\\\\\\\F10D\\\\\\\\\\\\\\"\\\\n}\\\\n*/\\\\n\\", \\"\\"]); diff --git a/test/__snapshots__/sourceMap-option.test.js.snap b/test/__snapshots__/sourceMap-option.test.js.snap new file mode 100644 index 00000000..bac0b795 --- /dev/null +++ b/test/__snapshots__/sourceMap-option.test.js.snap @@ -0,0 +1,255 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`sourceMap option false should not generate source map when source map is \`null\` from other loader: errors 1`] = `Array []`; + +exports[`sourceMap option false should not generate source map when source map is \`null\` from other loader: module (evaluated) 1`] = ` +Array [ + Array [ + 1, + ".class { + color: red; +} +", + "", + ], +] +`; + +exports[`sourceMap option false should not generate source map when source map is \`null\` from other loader: warnings 1`] = `Array []`; + +exports[`sourceMap option false should not generate source map when source map is \`undefined\` from other loader: errors 1`] = `Array []`; + +exports[`sourceMap option false should not generate source map when source map is \`undefined\` from other loader: module (evaluated) 1`] = ` +Array [ + Array [ + 1, + ".class { + color: red; +} +", + "", + ], +] +`; + +exports[`sourceMap option false should not generate source map when source map is \`undefined\` from other loader: warnings 1`] = `Array []`; + +exports[`sourceMap option false should not generate source map when source map is valid and it is string from other loader: errors 1`] = `Array []`; + +exports[`sourceMap option false should not generate source map when source map is valid and it is string from other loader: module (evaluated) 1`] = ` +Array [ + Array [ + 1, + ".class { + color: red; +} +", + "", + ], +] +`; + +exports[`sourceMap option false should not generate source map when source map is valid and it is string from other loader: warnings 1`] = `Array []`; + +exports[`sourceMap option false should not generate source map: errors 1`] = `Array []`; + +exports[`sourceMap option false should not generate source map: module (evaluated) 1`] = ` +Array [ + Array [ + 1, + ".class { + color: red; +} +", + "", + ], +] +`; + +exports[`sourceMap option false should not generate source map: warnings 1`] = `Array []`; + +exports[`sourceMap option false should not generate sourceMap when source map is valid from other loader: errors 1`] = `Array []`; + +exports[`sourceMap option false should not generate sourceMap when source map is valid from other loader: module (evaluated) 1`] = ` +Array [ + Array [ + 1, + ".class { + color: red; +} +", + "", + ], +] +`; + +exports[`sourceMap option false should not generate sourceMap when source map is valid from other loader: warnings 1`] = `Array []`; + +exports[`sourceMap option true should generate source map when source map is \`null\` from other loader: errors 1`] = `Array []`; + +exports[`sourceMap option true should generate source map when source map is \`null\` from other loader: module (evaluated) 1`] = ` +Array [ + Array [ + 1, + ".class { + color: red; +} +", + "", + Object { + "file": "basic.css", + "mappings": "AAAA;EACE,WAAW;CACZ", + "names": Array [], + "sourceRoot": "", + "sources": Array [ + "/replaced/original/path/", + ], + "sourcesContent": Array [ + ".class { + color: red; +} +", + ], + "version": 3, + }, + ], +] +`; + +exports[`sourceMap option true should generate source map when source map is \`null\` from other loader: warnings 1`] = `Array []`; + +exports[`sourceMap option true should generate source map when source map is \`undefined\` from other loader: errors 1`] = `Array []`; + +exports[`sourceMap option true should generate source map when source map is \`undefined\` from other loader: module (evaluated) 1`] = ` +Array [ + Array [ + 1, + ".class { + color: red; +} +", + "", + Object { + "file": "basic.css", + "mappings": "AAAA;EACE,WAAW;CACZ", + "names": Array [], + "sourceRoot": "", + "sources": Array [ + "/replaced/original/path/", + ], + "sourcesContent": Array [ + ".class { + color: red; +} +", + ], + "version": 3, + }, + ], +] +`; + +exports[`sourceMap option true should generate source map when source map is \`undefined\` from other loader: warnings 1`] = `Array []`; + +exports[`sourceMap option true should generate source map when source map is valid and it is string from other loader: errors 1`] = `Array []`; + +exports[`sourceMap option true should generate source map when source map is valid and it is string from other loader: module (evaluated) 1`] = ` +Array [ + Array [ + 1, + ".class { + color: red; +} +", + "", + Object { + "file": "basic.css", + "mappings": "AAAA;ECCE,WAAW;CACZ", + "names": Array [], + "sourceRoot": "", + "sources": Array [ + "/replaced/original/path/", + "/replaced/original/path/", + ], + "sourcesContent": Array [ + ".class { a: b c d; }", + ".class { + color: red; +} +", + ], + "version": 3, + }, + ], +] +`; + +exports[`sourceMap option true should generate source map when source map is valid and it is string from other loader: warnings 1`] = `Array []`; + +exports[`sourceMap option true should generate source map when source map is valid from other loader: errors 1`] = `Array []`; + +exports[`sourceMap option true should generate source map when source map is valid from other loader: module (evaluated) 1`] = ` +Array [ + Array [ + 1, + ".class { + color: red; +} +", + "", + Object { + "file": "basic.css", + "mappings": "AAAA;ECCE,WAAW;CACZ", + "names": Array [], + "sourceRoot": "", + "sources": Array [ + "/replaced/original/path/", + "/replaced/original/path/", + ], + "sourcesContent": Array [ + ".class { a: b c d; }", + ".class { + color: red; +} +", + ], + "version": 3, + }, + ], +] +`; + +exports[`sourceMap option true should generate source map when source map is valid from other loader: warnings 1`] = `Array []`; + +exports[`sourceMap option true should generate source map: errors 1`] = `Array []`; + +exports[`sourceMap option true should generate source map: module (evaluated) 1`] = ` +Array [ + Array [ + 1, + ".class { + color: red; +} +", + "", + Object { + "file": "basic.css", + "mappings": "AAAA;EACE,WAAW;CACZ", + "names": Array [], + "sourceRoot": "", + "sources": Array [ + "/replaced/original/path/", + ], + "sourcesContent": Array [ + ".class { + color: red; +} +", + ], + "version": 3, + }, + ], +] +`; + +exports[`sourceMap option true should generate source map: warnings 1`] = `Array []`; diff --git a/test/__snapshots__/url-option.test.js.snap b/test/__snapshots__/url-option.test.js.snap index 1481d736..06334fcc 100644 --- a/test/__snapshots__/url-option.test.js.snap +++ b/test/__snapshots__/url-option.test.js.snap @@ -187,7 +187,7 @@ b { exports[`url option false: module 1`] = ` "exports = module.exports = require(\\"../../../lib/runtime/api.js\\")(false); // imports -exports.i(require(\\"-!../../../index.js??ref--4!./imported.css\\"), \\"\\"); +exports.i(require(\\"-!../../../index.js??ref--4-0!./imported.css\\"), \\"\\"); // module exports.push([module.id, \\".class {\\\\n background: url('img.png');\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\\\\\"img.png\\\\\\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(img.png);\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\\\\\"img.png#hash\\\\\\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\\\n \\\\\\"img.png\\\\\\"\\\\n );\\\\n}\\\\n\\\\n.class {\\\\n background: green url( 'img.png' ) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url( \\\\\\"img.png\\\\\\" ) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url( img.png ) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(~package/img.png) url(other-img.png) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url( \\\\\\"img img.png\\\\\\" ) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url( 'img img.png' ) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(/img.png) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) url(//example.com/image.png) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background-image: url(\\\\\\"data:image/svg+xml;charset=utf-8,\\\\\\");\\\\n}\\\\n\\\\n.class {\\\\n background-image: url(\\\\\\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%2523007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E\\\\\\");\\\\n}\\\\n\\\\n.class {\\\\n filter: url('data:image/svg+xml;charset=utf-8,#filter');\\\\n}\\\\n\\\\n.class {\\\\n filter: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%5C%22%3E%3Cfilter%20id%3D%5C%22filter%5C%22%3E%3CfeGaussianBlur%20in%3D%5C%22SourceAlpha%5C%22%20stdDeviation%3D%5C%220%5C%22%20%2F%3E%3CfeOffset%20dx%3D%5C%221%5C%22%20dy%3D%5C%222%5C%22%20result%3D%5C%22offsetblur%5C%22%20%2F%3E%3CfeFlood%20flood-color%3D%5C%22rgba(255%2C255%2C255%2C1)%5C%22%20%2F%3E%3CfeComposite%20in2%3D%5C%22offsetblur%5C%22%20operator%3D%5C%22in%5C%22%20%2F%3E%3CfeMerge%3E%3CfeMergeNode%20%2F%3E%3CfeMergeNode%20in%3D%5C%22SourceGraphic%5C%22%20%2F%3E%3C%2FfeMerge%3E%3C%2Ffilter%3E%3C%2Fsvg%3E%23filter');\\\\n}\\\\n\\\\n.highlight {\\\\n filter: url(#highlight);\\\\n}\\\\n\\\\n.highlight {\\\\n filter: url('#line-marker');\\\\n}\\\\n\\\\n@font-face {\\\\n src: url(font.woff) format('woff'),\\\\n url('font.woff2') format('woff2'),\\\\n url(\\\\\\"font.eot\\\\\\") format('eot'),\\\\n url(~package/font.ttf) format('truetype'),\\\\n url(\\\\\\"font with spaces.eot\\\\\\") format(\\\\\\"embedded-opentype\\\\\\"),\\\\n url('font.svg#svgFontName') format('svg'),\\\\n url('font.woff2?foo=bar') format('woff2'),\\\\n url(\\\\\\"font.eot?#iefix\\\\\\") format('embedded-opentype'),\\\\n url(\\\\\\"font with spaces.eot?#iefix\\\\\\") format('embedded-opentype');\\\\n}\\\\n\\\\n@media (min-width: 500px) {\\\\n body {\\\\n background: url(\\\\\\"img.png\\\\\\");\\\\n }\\\\n}\\\\n\\\\na {\\\\n content: \\\\\\"do not use url(path)\\\\\\";\\\\n}\\\\n\\\\nb {\\\\n content: 'do not \\\\\\"use\\\\\\" url(path)';\\\\n}\\\\n\\\\n@keyframes anim {\\\\n background: green url('img.png') xyz;\\\\n}\\\\n\\\\n.a {\\\\n background-image: -webkit-image-set(url('img1x.png') 1x, url('img2x.png') 2x)\\\\n}\\\\n\\\\n.a {\\\\n background-image: image-set(url('img1x.png') 1x, url('img2x.png') 2x)\\\\n}\\\\n\\\\n.class {\\\\n background: green url() xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url('') xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(\\\\\\"\\\\\\") xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(' ') xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(\\\\n ) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(https://raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(//raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\\\\\"img.png?foo\\\\\\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\\\\\"img.png?foo=bar\\\\\\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\\\\\"img.png?foo=bar#hash\\\\\\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\\\\\"img.png?foo=bar#hash\\\\\\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\\\\\"img.png?\\\\\\");\\\\n}\\\\n\\", \\"\\"]); @@ -384,7 +384,7 @@ exports[`url option true: module 1`] = ` "var escape = require(\\"../../../lib/runtime/escape.js\\"); exports = module.exports = require(\\"../../../lib/runtime/api.js\\")(false); // imports -exports.i(require(\\"-!../../../index.js??ref--4!./imported.css\\"), \\"\\"); +exports.i(require(\\"-!../../../index.js??ref--4-0!./imported.css\\"), \\"\\"); // module exports.push([module.id, \\".class {\\\\n background: url(\\" + escape(require(\\"./img.png\\")) + \\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\" + escape(require(\\"./img.png\\")) + \\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\" + escape(require(\\"./img.png\\")) + \\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\" + escape(require(\\"./img.png\\") + \\"#hash\\") + \\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\" + escape(require(\\"./img.png\\")) + \\");\\\\n}\\\\n\\\\n.class {\\\\n background: green url(\\" + escape(require(\\"./img.png\\")) + \\") xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(\\" + escape(require(\\"./img.png\\")) + \\") xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(\\" + escape(require(\\"./img.png\\")) + \\") xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(\\" + escape(require(\\"package/img.png\\")) + \\") url(\\" + escape(require(\\"./other-img.png\\")) + \\") xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(\\" + escape(require(\\"./img img.png\\")) + \\") xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(\\" + escape(require(\\"./img img.png\\")) + \\") xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(/img.png) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) url(//example.com/image.png) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background-image: url(\\\\\\"data:image/svg+xml;charset=utf-8,\\\\\\");\\\\n}\\\\n\\\\n.class {\\\\n background-image: url(\\\\\\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%2523007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E\\\\\\");\\\\n}\\\\n\\\\n.class {\\\\n filter: url('data:image/svg+xml;charset=utf-8,#filter');\\\\n}\\\\n\\\\n.class {\\\\n filter: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%5C%22%3E%3Cfilter%20id%3D%5C%22filter%5C%22%3E%3CfeGaussianBlur%20in%3D%5C%22SourceAlpha%5C%22%20stdDeviation%3D%5C%220%5C%22%20%2F%3E%3CfeOffset%20dx%3D%5C%221%5C%22%20dy%3D%5C%222%5C%22%20result%3D%5C%22offsetblur%5C%22%20%2F%3E%3CfeFlood%20flood-color%3D%5C%22rgba(255%2C255%2C255%2C1)%5C%22%20%2F%3E%3CfeComposite%20in2%3D%5C%22offsetblur%5C%22%20operator%3D%5C%22in%5C%22%20%2F%3E%3CfeMerge%3E%3CfeMergeNode%20%2F%3E%3CfeMergeNode%20in%3D%5C%22SourceGraphic%5C%22%20%2F%3E%3C%2FfeMerge%3E%3C%2Ffilter%3E%3C%2Fsvg%3E%23filter');\\\\n}\\\\n\\\\n.highlight {\\\\n filter: url(#highlight);\\\\n}\\\\n\\\\n.highlight {\\\\n filter: url('#line-marker');\\\\n}\\\\n\\\\n@font-face {\\\\n src: url(\\" + escape(require(\\"./font.woff\\")) + \\") format('woff'),\\\\n url(\\" + escape(require(\\"./font.woff2\\")) + \\") format('woff2'),\\\\n url(\\" + escape(require(\\"./font.eot\\")) + \\") format('eot'),\\\\n url(\\" + escape(require(\\"package/font.ttf\\")) + \\") format('truetype'),\\\\n url(\\" + escape(require(\\"./font with spaces.eot\\")) + \\") format(\\\\\\"embedded-opentype\\\\\\"),\\\\n url(\\" + escape(require(\\"./font.svg\\") + \\"#svgFontName\\") + \\") format('svg'),\\\\n url(\\" + escape(require(\\"./font.woff2?foo=bar\\")) + \\") format('woff2'),\\\\n url(\\" + escape(require(\\"./font.eot\\") + \\"?#iefix\\") + \\") format('embedded-opentype'),\\\\n url(\\" + escape(require(\\"./font with spaces.eot\\") + \\"?#iefix\\") + \\") format('embedded-opentype');\\\\n}\\\\n\\\\n@media (min-width: 500px) {\\\\n body {\\\\n background: url(\\" + escape(require(\\"./img.png\\")) + \\");\\\\n }\\\\n}\\\\n\\\\na {\\\\n content: \\\\\\"do not use url(path)\\\\\\";\\\\n}\\\\n\\\\nb {\\\\n content: 'do not \\\\\\"use\\\\\\" url(path)';\\\\n}\\\\n\\\\n@keyframes anim {\\\\n background: green url(\\" + escape(require(\\"./img.png\\")) + \\") xyz;\\\\n}\\\\n\\\\n.a {\\\\n background-image: -webkit-image-set(url(\\" + escape(require(\\"./img1x.png\\")) + \\") 1x, url(\\" + escape(require(\\"./img2x.png\\")) + \\") 2x)\\\\n}\\\\n\\\\n.a {\\\\n background-image: image-set(url(\\" + escape(require(\\"./img1x.png\\")) + \\") 1x, url(\\" + escape(require(\\"./img2x.png\\")) + \\") 2x)\\\\n}\\\\n\\\\n.class {\\\\n background: green url() xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url('') xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(\\\\\\"\\\\\\") xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url('') xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(\\\\n ) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(https://raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: green url(//raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz;\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\" + escape(require(\\"./img.png?foo\\")) + \\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\" + escape(require(\\"./img.png?foo=bar\\")) + \\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\" + escape(require(\\"./img.png?foo=bar\\") + \\"#hash\\") + \\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\" + escape(require(\\"./img.png?foo=bar\\") + \\"#hash\\") + \\");\\\\n}\\\\n\\\\n.class {\\\\n background: url(\\" + escape(require(\\"./img.png?\\")) + \\");\\\\n}\\\\n\\", \\"\\"]); diff --git a/test/fixtures/source-map-loader.js b/test/fixtures/source-map-loader.js new file mode 100644 index 00000000..5b48d42e --- /dev/null +++ b/test/fixtures/source-map-loader.js @@ -0,0 +1,5 @@ +module.exports = function loader(source) { + const cb = this.async(); + + cb(null, source, this.query.sourceMap); +}; diff --git a/test/fixtures/source-map/basic.css b/test/fixtures/source-map/basic.css new file mode 100644 index 00000000..19fce739 --- /dev/null +++ b/test/fixtures/source-map/basic.css @@ -0,0 +1,3 @@ +.class { + color: red; +} diff --git a/test/helpers.js b/test/helpers.js index cdcc5acc..a653a9d8 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -146,38 +146,6 @@ exports.testRaw = function testRaw(name, input, result, query) { }); }; -exports.testWithMap = function test(name, input, map, result, query, modules) { - it(name, (done) => { - runLoader( - cssLoader, - input, - map, - { - query, - }, - (err, output) => { - if (err) { - return done(err); - } - assetEvaluated(output, result, modules); - return done(); - } - ); - }); -}; - -exports.testMap = function test(name, input, map, addOptions, result, modules) { - it(name, (done) => { - runLoader(cssLoader, input, map, addOptions, (err, output) => { - if (err) { - return done(err); - } - assetEvaluated(output, result, modules); - return done(); - }); - }); -}; - exports.testLocals = function testLocals(name, input, result, query, modules) { it(name, (done) => { runLoader( @@ -237,10 +205,26 @@ const moduleConfig = (config) => { : [ { test: (config.loader && config.loader.test) || /\.css$/, - use: { - loader: path.resolve(__dirname, '../index.js'), - options: (config.loader && config.loader.options) || {}, - }, + use: [ + { + loader: path.resolve(__dirname, '../index.js'), + options: (config.loader && config.loader.options) || {}, + }, + ].concat( + config.sourceMap + ? [ + { + loader: path.resolve( + __dirname, + './fixtures/source-map-loader.js' + ), + options: { + sourceMap: config.sourceMap, + }, + }, + ] + : [] + ), }, { test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/, @@ -280,6 +264,7 @@ exports.webpack = function compile(fixture, config = {}, options = {}) { runtimeChunk: true, }, }; + // Compiler Options // eslint-disable-next-line no-param-reassign options = Object.assign({ output: false }, options); @@ -317,3 +302,16 @@ function normalizeErrors(errors) { } exports.normalizeErrors = normalizeErrors; + +function normalizeSourceMap(module) { + return module.map((m) => { + if (m[3]) { + // eslint-disable-next-line no-param-reassign + m[3].sources = m[3].sources.map(() => '/replaced/original/path/'); + } + + return m; + }); +} + +exports.normalizeSourceMap = normalizeSourceMap; diff --git a/test/sourceMap-option.test.js b/test/sourceMap-option.test.js new file mode 100644 index 00000000..76d24369 --- /dev/null +++ b/test/sourceMap-option.test.js @@ -0,0 +1,239 @@ +const { webpack, evaluated, normalizeSourceMap } = require('./helpers'); + +describe('sourceMap option', () => { + describe('true', () => { + it('should generate source map', async () => { + const config = { + loader: { + options: { + sourceMap: true, + }, + }, + }; + const testId = './source-map/basic.css'; + const stats = await webpack(testId, config); + const { modules } = stats.toJson(); + const module = modules.find((m) => m.id === testId); + + expect(normalizeSourceMap(evaluated(module.source))).toMatchSnapshot( + 'module (evaluated)' + ); + expect(stats.compilation.warnings).toMatchSnapshot('warnings'); + expect(stats.compilation.errors).toMatchSnapshot('errors'); + }); + + it('should generate source map when source map is `null` from other loader', async () => { + const config = { + loader: { + options: { + sourceMap: true, + }, + }, + sourceMap: null, + }; + const testId = './source-map/basic.css'; + const stats = await webpack(testId, config); + const { modules } = stats.toJson(); + const module = modules.find((m) => m.id === testId); + + expect(normalizeSourceMap(evaluated(module.source))).toMatchSnapshot( + 'module (evaluated)' + ); + expect(stats.compilation.warnings).toMatchSnapshot('warnings'); + expect(stats.compilation.errors).toMatchSnapshot('errors'); + }); + + it('should generate source map when source map is `undefined` from other loader', async () => { + const config = { + loader: { + options: { + sourceMap: true, + }, + }, + // eslint-disable-next-line no-undefined + sourceMap: undefined, + }; + const testId = './source-map/basic.css'; + const stats = await webpack(testId, config); + const { modules } = stats.toJson(); + const module = modules.find((m) => m.id === testId); + + expect(normalizeSourceMap(evaluated(module.source))).toMatchSnapshot( + 'module (evaluated)' + ); + expect(stats.compilation.warnings).toMatchSnapshot('warnings'); + expect(stats.compilation.errors).toMatchSnapshot('errors'); + }); + + it('should generate source map when source map is valid from other loader', async () => { + const config = { + loader: { + options: { + sourceMap: true, + }, + }, + sourceMap: { + file: 'test.css', + mappings: 'AAAA,SAAS,SAAS,EAAE', + names: [], + sourceRoot: '', + sources: ['/folder/test.css'], + sourcesContent: ['.class { a: b c d; }'], + version: 3, + }, + }; + const testId = './source-map/basic.css'; + const stats = await webpack(testId, config); + const { modules } = stats.toJson(); + const module = modules.find((m) => m.id === testId); + + expect(normalizeSourceMap(evaluated(module.source))).toMatchSnapshot( + 'module (evaluated)' + ); + expect(stats.compilation.warnings).toMatchSnapshot('warnings'); + expect(stats.compilation.errors).toMatchSnapshot('errors'); + }); + + it('should generate source map when source map is valid and it is string from other loader', async () => { + const config = { + loader: { + options: { + sourceMap: true, + }, + }, + sourceMap: JSON.stringify({ + file: 'test.css', + mappings: 'AAAA,SAAS,SAAS,EAAE', + names: [], + sourceRoot: '', + sources: ['/folder/test.css'], + sourcesContent: ['.class { a: b c d; }'], + version: 3, + }), + }; + const testId = './source-map/basic.css'; + const stats = await webpack(testId, config); + const { modules } = stats.toJson(); + const module = modules.find((m) => m.id === testId); + + expect(normalizeSourceMap(evaluated(module.source))).toMatchSnapshot( + 'module (evaluated)' + ); + expect(stats.compilation.warnings).toMatchSnapshot('warnings'); + expect(stats.compilation.errors).toMatchSnapshot('errors'); + }); + }); + + describe('false', () => { + it('should not generate source map', async () => { + const config = { + loader: { + options: { + sourceMap: false, + }, + }, + }; + const testId = './source-map/basic.css'; + const stats = await webpack(testId, config); + const { modules } = stats.toJson(); + const module = modules.find((m) => m.id === testId); + + expect(evaluated(module.source)).toMatchSnapshot('module (evaluated)'); + expect(stats.compilation.warnings).toMatchSnapshot('warnings'); + expect(stats.compilation.errors).toMatchSnapshot('errors'); + }); + + it('should not generate source map when source map is `null` from other loader', async () => { + const config = { + loader: { + options: { + sourceMap: false, + }, + }, + sourceMap: null, + }; + const testId = './source-map/basic.css'; + const stats = await webpack(testId, config); + const { modules } = stats.toJson(); + const module = modules.find((m) => m.id === testId); + + expect(evaluated(module.source)).toMatchSnapshot('module (evaluated)'); + expect(stats.compilation.warnings).toMatchSnapshot('warnings'); + expect(stats.compilation.errors).toMatchSnapshot('errors'); + }); + + it('should not generate source map when source map is `undefined` from other loader', async () => { + const config = { + loader: { + options: { + sourceMap: false, + }, + }, + // eslint-disable-next-line no-undefined + sourceMap: undefined, + }; + const testId = './source-map/basic.css'; + const stats = await webpack(testId, config); + const { modules } = stats.toJson(); + const module = modules.find((m) => m.id === testId); + + expect(evaluated(module.source)).toMatchSnapshot('module (evaluated)'); + expect(stats.compilation.warnings).toMatchSnapshot('warnings'); + expect(stats.compilation.errors).toMatchSnapshot('errors'); + }); + + it('should not generate sourceMap when source map is valid from other loader', async () => { + const config = { + loader: { + options: { + sourceMap: false, + }, + }, + sourceMap: { + file: 'test.css', + mappings: 'AAAA,SAAS,SAAS,EAAE', + names: [], + sourceRoot: '', + sources: ['/folder/test.css'], + sourcesContent: ['.class { a: b c d; }'], + version: 3, + }, + }; + const testId = './source-map/basic.css'; + const stats = await webpack(testId, config); + const { modules } = stats.toJson(); + const module = modules.find((m) => m.id === testId); + + expect(evaluated(module.source)).toMatchSnapshot('module (evaluated)'); + expect(stats.compilation.warnings).toMatchSnapshot('warnings'); + expect(stats.compilation.errors).toMatchSnapshot('errors'); + }); + + it('should not generate source map when source map is valid and it is string from other loader', async () => { + const config = { + loader: { + options: { + sourceMap: false, + }, + }, + sourceMap: JSON.stringify({ + file: 'test.css', + mappings: 'AAAA,SAAS,SAAS,EAAE', + names: [], + sourceRoot: '', + sources: ['/folder/test.css'], + sourcesContent: ['.class { a: b c d; }'], + version: 3, + }), + }; + const testId = './source-map/basic.css'; + const stats = await webpack(testId, config); + const { modules } = stats.toJson(); + const module = modules.find((m) => m.id === testId); + + expect(evaluated(module.source)).toMatchSnapshot('module (evaluated)'); + expect(stats.compilation.warnings).toMatchSnapshot('warnings'); + expect(stats.compilation.errors).toMatchSnapshot('errors'); + }); + }); +}); diff --git a/test/sourceMap.test.js b/test/sourceMap.test.js deleted file mode 100644 index 8a7f8369..00000000 --- a/test/sourceMap.test.js +++ /dev/null @@ -1,289 +0,0 @@ -const { testWithMap, testMap } = require('./helpers'); - -describe('source maps', () => { - testWithMap( - "falsy: null map doesn't cause an error", - '.class { a: b c d; }', - null, - [[1, '.class { a: b c d; }', '']] - ); - testWithMap( - "falsy: undefined map doesn't cause an error", - '.class { a: b c d; }', - null, - [[1, '.class { a: b c d; }', '']] - ); - testWithMap( - "should don't generate sourceMap when `sourceMap: false` and map exists", - '.class { a: b c d; }', - { - file: 'test.css', - mappings: 'AAAA,SAAS,SAAS,EAAE', - names: [], - sourceRoot: '', - sources: ['/folder/test.css'], - sourcesContent: ['.class { a: b c d; }'], - version: 3, - }, - [[1, '.class { a: b c d; }', '']], - { - sourceMap: false, - } - ); - testWithMap( - "should don't generate sourceMap when `sourceMap: true` and map exists", - '.class { a: b c d; }', - { - file: 'test.css', - mappings: 'AAAA,SAAS,SAAS,EAAE', - names: [], - sourceRoot: '', - sources: ['/folder/test.css'], - sourcesContent: ['.class { a: b c d; }'], - version: 3, - }, - [ - [ - 1, - '.class { a: b c d; }', - '', - { - file: 'test.css', - mappings: 'AAAA,SAAS,SAAS,EAAE', - names: [], - sourceRoot: '', - sources: ['/folder/test.css'], - sourcesContent: ['.class { a: b c d; }'], - version: 3, - }, - ], - ], - { - sourceMap: true, - } - ); - testWithMap( - "should don't generate sourceMap when `sourceMap: true` and map exists and string", - '.class { a: b c d; }', - JSON.stringify({ - file: 'test.css', - mappings: 'AAAA,SAAS,SAAS,EAAE', - names: [], - sourceRoot: '', - sources: ['/folder/test.css'], - sourcesContent: ['.class { a: b c d; }'], - version: 3, - }), - [ - [ - 1, - '.class { a: b c d; }', - '', - { - file: 'test.css', - mappings: 'AAAA,SAAS,SAAS,EAAE', - names: [], - sourceRoot: '', - sources: ['/folder/test.css'], - sourcesContent: ['.class { a: b c d; }'], - version: 3, - }, - ], - ], - { - sourceMap: true, - } - ); - testMap( - 'generate sourceMap (1 loader)', - '.class { a: b c d; }', - null, - { - loaders: [{ request: '/path/css-loader' }], - resource: '/folder/test.css', - request: '/path/css-loader!/folder/test.css', - query: '?sourceMap', - }, - [ - [ - 1, - '.class { a: b c d; }', - '', - { - file: 'test.css', - mappings: 'AAAA,SAAS,SAAS,EAAE', - names: [], - sourceRoot: '', - sources: ['/folder/test.css'], - sourcesContent: ['.class { a: b c d; }'], - version: 3, - }, - ], - ] - ); - testMap( - 'generate sourceMap (1 loader, relative)', - '.class { a: b c d; }', - null, - { - loaders: [{ request: '/path/css-loader' }], - resource: '/folder/test.css', - request: '/path/css-loader!/folder/test.css', - query: '?sourceMap', - }, - [ - [ - 1, - '.class { a: b c d; }', - '', - { - file: 'test.css', - mappings: 'AAAA,SAAS,SAAS,EAAE', - names: [], - sourceRoot: '', - sources: ['/folder/test.css'], - sourcesContent: ['.class { a: b c d; }'], - version: 3, - }, - ], - ] - ); - testMap( - 'generate sourceMap (1 loader, data url)', - ".class { background-image: url(\"data:image/svg+xml;charset=utf-8,\"); }", - null, - { - loaders: [{ request: '/path/css-loader' }], - resource: '/folder/test.css', - request: '/path/css-loader!/folder/test.css', - query: '?sourceMap', - }, - [ - [ - 1, - ".class { background-image: url(\"data:image/svg+xml;charset=utf-8,\"); }", - '', - { - file: 'test.css', - mappings: 'AAAA,SAAS,6WAA6W,EAAE', - names: [], - sourceRoot: '', - sources: ['/folder/test.css'], - sourcesContent: [ - ".class { background-image: url(\"data:image/svg+xml;charset=utf-8,\"); }", - ], - version: 3, - }, - ], - ] - ); - testMap( - 'generate sourceMap (1 loader, encoded data url)', - '.class { background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%23007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E"); }', - null, - { - loaders: [{ request: '/path/css-loader' }], - resource: '/folder/test.css', - request: '/path/css-loader!/folder/test.css', - query: '?sourceMap', - }, - [ - [ - 1, - '.class { background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%23007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E"); }', - '', - { - file: 'test.css', - mappings: 'AAAA,SAAS,mmBAAmmB,EAAE', - names: [], - sourceRoot: '', - sources: ['/folder/test.css'], - sourcesContent: [ - '.class { background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%23007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E"); }', - ], - version: 3, - }, - ], - ] - ); - testMap( - 'generate sourceMap (2 loaders)', - '.class { a: b c d; }', - null, - { - loaders: [ - { request: '/path/css-loader' }, - { request: '/path/sass-loader' }, - ], - resource: '/folder/test.scss', - request: '/path/css-loader!/path/sass-loader!/folder/test.scss', - query: '?sourceMap', - }, - [ - [ - 1, - '.class { a: b c d; }', - '', - { - file: 'test.scss', - mappings: 'AAAA,SAAS,SAAS,EAAE', - names: [], - sourceRoot: '', - sources: ['/folder/test.scss'], - sourcesContent: ['.class { a: b c d; }'], - version: 3, - }, - ], - ] - ); - testMap( - 'generate sourceMap (2 loaders) and map exist', - '.class { a: b c d; }', - { - file: 'test.scss', - mappings: 'AAAA,SAAS,SAAS,EAAE', - names: [], - sourceRoot: '', - sources: ['/folder/test.scss'], - sourcesContent: ['.class { a: b c d; }'], - version: 3, - }, - { - loaders: [ - { request: '/path/css-loader' }, - { request: '/path/sass-loader' }, - ], - resource: '/folder/test.scss', - request: '/path/css-loader!/path/sass-loader!/folder/test.scss', - query: '?sourceMap', - }, - [ - [ - 1, - '.class { a: b c d; }', - '', - { - file: 'test.scss', - mappings: 'AAAA,SAAS,SAAS,EAAE', - names: [], - sourceRoot: '', - sources: ['/folder/test.scss'], - sourcesContent: ['.class { a: b c d; }'], - version: 3, - }, - ], - ] - ); - testMap( - "don't generate sourceMap (1 loader)", - '.class { a: b c d; }', - null, - { - loaders: [{ request: '/path/css-loader' }], - resource: '/folder/test.css', - request: '/path/css-loader!/folder/test.css', - query: '?sourceMap=false', - }, - [[1, '.class { a: b c d; }', '']] - ); -});