diff --git a/src/index.js b/src/index.js index b4d7c311..8729e4b3 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,7 @@ Author Tobias Koppers @sokra */ import validateOptions from 'schema-utils'; +import RequestShortener from 'webpack/lib/RequestShortener'; import postcss from 'postcss'; import postcssPkg from 'postcss/package.json'; @@ -76,7 +77,13 @@ export default function loader(content, map, meta) { map: options.sourceMap ? { // Some loaders (example `"postcss-loader": "1.x.x"`) always generates source map, we should remove it - prev: sourceMap && map ? normalizeSourceMap(map) : null, + prev: + sourceMap && map + ? normalizeSourceMap( + map, + new RequestShortener(this.rootContext) + ) + : null, inline: false, annotation: false, } diff --git a/src/utils.js b/src/utils.js index c5b00d10..b9b8df59 100644 --- a/src/utils.js +++ b/src/utils.js @@ -156,30 +156,35 @@ function getModulesPlugins(options, loaderContext) { ]; } -function normalizeSourceMap(map) { +function normalizeSourceMap(map, requestShortener) { let newMap = map; // Some loader emit source map as string - // Strip any JSON XSSI avoidance prefix from the string (as documented in the source maps specification), and then parse the string as JSON. if (typeof newMap === 'string') { newMap = JSON.parse(newMap); } + console.log(newMap); + // Source maps should use forward slash because it is URLs (https://github.com/mozilla/source-map/issues/91) // We should normalize path because previous loaders like `sass-loader` using backslash when generate source map if (newMap.file) { - newMap.file = normalizePath(newMap.file); + newMap.file = requestShortener.shorten(newMap.file); } if (newMap.sourceRoot) { - newMap.sourceRoot = normalizePath(newMap.sourceRoot); + newMap.sourceRoot = requestShortener.shorten(newMap.sourceRoot); } if (newMap.sources) { - newMap.sources = newMap.sources.map((source) => normalizePath(source)); + newMap.sources = newMap.sources.map((source) => + requestShortener.shorten(source) + ); } + console.log(newMap); + return newMap; } diff --git a/test/__snapshots__/loader.test.js.snap b/test/__snapshots__/loader.test.js.snap index 5ec0987b..160d7a38 100644 --- a/test/__snapshots__/loader.test.js.snap +++ b/test/__snapshots__/loader.test.js.snap @@ -1,730 +1,61 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`loader should have same "contenthash" with "css-loader" and source maps: errors 1`] = `Array []`; +exports[`loader should have same "contenthash" with "css-loader" and with source maps: errors 1`] = `Array []`; -exports[`loader should have same "contenthash" with "css-loader" and source maps: module 1`] = ` +exports[`loader should have same "contenthash" with "css-loader" and with source maps: module 1`] = ` Array [ "main.54b9712c1981e48c12c4.bundle.js", ] `; -exports[`loader should have same "contenthash" with "css-loader" and source maps: warnings 1`] = `Array []`; +exports[`loader should have same "contenthash" with "css-loader" and with source maps: warnings 1`] = `Array []`; -exports[`loader should have same "contenthash" with "postcss-loader" and source maps: errors 1`] = `Array []`; +exports[`loader should have same "contenthash" with "css-loader" and without source maps: errors 1`] = `Array []`; -exports[`loader should have same "contenthash" with "postcss-loader" and source maps: module 1`] = ` +exports[`loader should have same "contenthash" with "css-loader" and without source maps: module 1`] = ` Array [ - "main.d77dd6564bc6e6297cd4.bundle.js", -] -`; - -exports[`loader should have same "contenthash" with "postcss-loader" and source maps: warnings 1`] = `Array []`; - -exports[`loader should have same "contenthash" with "sass-loader" and source maps: errors 1`] = `Array []`; - -exports[`loader should have same "contenthash" with "sass-loader" and source maps: module 1`] = ` -Array [ - "main.151589c7e12ebfd445e7.bundle.js", -] -`; - -exports[`loader should have same "contenthash" with "sass-loader" and source maps: warnings 1`] = `Array []`; - -exports[`loader should reuse \`ast\` from "postcss-loader": errors 1`] = `Array []`; - -exports[`loader should reuse \`ast\` from "postcss-loader": module 1`] = ` -"// Imports -var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../src/runtime/api.js\\"); -var ___CSS_LOADER_GET_URL_IMPORT___ = require(\\"../../../src/runtime/getUrl.js\\"); -var ___CSS_LOADER_URL_IMPORT_0___ = require(\\"./img1x.png\\"); -var ___CSS_LOADER_URL_IMPORT_1___ = require(\\"./img2x.png\\"); -exports = ___CSS_LOADER_API_IMPORT___(false); -var ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___); -var ___CSS_LOADER_URL_REPLACEMENT_1___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_1___); -// Module -exports.push([module.id, \\":root {\\\\n --fontSize: 1rem;\\\\n --mainColor: rgba(18,52,86,0.47059);\\\\n --secondaryColor: rgba(102, 51, 153, 0.9);\\\\n}\\\\n\\\\nhtml {\\\\n overflow-x: hidden;\\\\n overflow-y: auto;\\\\n overflow: hidden auto;\\\\n}\\\\n\\\\n@media (max-width: 50rem) {\\\\n body {\\\\n color: rgba(18,52,86,0.47059);\\\\n color: var(--mainColor);\\\\n font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;\\\\n font-size: 1rem;\\\\n font-size: var(--fontSize);\\\\n line-height: calc(1rem * 1.5);\\\\n line-height: calc(var(--fontSize) * 1.5);\\\\n word-wrap: break-word;\\\\n padding-left: calc(1rem / 2 + 1px);\\\\n padding-right: calc(1rem / 2 + 1px);\\\\n padding-left: calc(var(--fontSize) / 2 + 1px);\\\\n padding-right: calc(var(--fontSize) / 2 + 1px);\\\\n }\\\\n}\\\\n\\\\nh1,h2,h3,h4,h5,h6 {\\\\n margin-top: 0;\\\\n margin-bottom: 0;\\\\n}\\\\n\\\\nmain.hero, .hero.main {\\\\n background-image: url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\");\\\\n}\\\\n\\\\n@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {\\\\n\\\\nmain.hero, .hero.main {\\\\n background-image: url(\\" + ___CSS_LOADER_URL_REPLACEMENT_1___ + \\");\\\\n}\\\\n}\\\\n\\\\nmain.hero, .hero.main {\\\\n background-image: -webkit-image-set(url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\") 1x, url(\\" + ___CSS_LOADER_URL_REPLACEMENT_1___ + \\") 2x);\\\\n background-image: image-set(url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\") 1x, url(\\" + ___CSS_LOADER_URL_REPLACEMENT_1___ + \\") 2x);\\\\n}\\\\n\\\\na {\\\\n color: rgba(0, 0, 255, 0.9)\\\\n}\\\\n\\\\na:hover {\\\\n color: #639;\\\\n }\\\\n\\", \\"\\"]); -// Exports -module.exports = exports; -" -`; - -exports[`loader should reuse \`ast\` from "postcss-loader": result 1`] = ` -Array [ - Array [ - "./postcss-present-env/source.css", - ":root { - --fontSize: 1rem; - --mainColor: rgba(18,52,86,0.47059); - --secondaryColor: rgba(102, 51, 153, 0.9); -} - -html { - overflow-x: hidden; - overflow-y: auto; - overflow: hidden auto; -} - -@media (max-width: 50rem) { - body { - color: rgba(18,52,86,0.47059); - color: var(--mainColor); - font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif; - font-size: 1rem; - font-size: var(--fontSize); - line-height: calc(1rem * 1.5); - line-height: calc(var(--fontSize) * 1.5); - word-wrap: break-word; - padding-left: calc(1rem / 2 + 1px); - padding-right: calc(1rem / 2 + 1px); - padding-left: calc(var(--fontSize) / 2 + 1px); - padding-right: calc(var(--fontSize) / 2 + 1px); - } -} - -h1,h2,h3,h4,h5,h6 { - margin-top: 0; - margin-bottom: 0; -} - -main.hero, .hero.main { - background-image: url(/webpack/public/path/img1x.png); -} - -@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { - -main.hero, .hero.main { - background-image: url(/webpack/public/path/img2x.png); -} -} - -main.hero, .hero.main { - background-image: -webkit-image-set(url(/webpack/public/path/img1x.png) 1x, url(/webpack/public/path/img2x.png) 2x); - background-image: image-set(url(/webpack/public/path/img1x.png) 1x, url(/webpack/public/path/img2x.png) 2x); -} - -a { - color: rgba(0, 0, 255, 0.9) -} - -a:hover { - color: #639; - } -", - "", - ], -] -`; - -exports[`loader should reuse \`ast\` from "postcss-loader": warnings 1`] = `Array []`; - -exports[`loader should throw error on invalid css syntax: errors 1`] = ` -Array [ - "ModuleBuildError: Module build failed (from \`replaced original path\`): -CssSyntaxError - -(2:3) Unknown word - - 1 | .some { -> 2 | invalid css; - | ^ - 3 | } - 4 | -", -] -`; - -exports[`loader should throw error on invalid css syntax: warnings 1`] = `Array []`; - -exports[`loader should throws error when no loader(s) for assets: errors 1`] = ` -Array [ - "ModuleParseError: Module parse failed: Unexpected character '�' (1:0) -You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders -(Source code omitted for this binary file)", -] -`; - -exports[`loader should throws error when no loader(s) for assets: warnings 1`] = `Array []`; - -exports[`loader should work with "asset" module type: errors 1`] = `Array []`; - -exports[`loader should work with "asset" module type: module 1`] = ` -"// Imports -var ___CSS_LOADER_API_IMPORT___ = require(\\"../../src/runtime/api.js\\"); -var ___CSS_LOADER_AT_RULE_IMPORT_0___ = require(\\"-!../../src/index.js!./imported.css\\"); -var ___CSS_LOADER_GET_URL_IMPORT___ = require(\\"../../src/runtime/getUrl.js\\"); -var ___CSS_LOADER_URL_IMPORT_0___ = require(\\"./url/img.png\\"); -exports = ___CSS_LOADER_API_IMPORT___(false); -exports.i(___CSS_LOADER_AT_RULE_IMPORT_0___); -var ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___); -// Module -exports.push([module.id, \\"@charset \\\\\\"UTF-8\\\\\\";\\\\n\\\\n/* Comment */\\\\n\\\\n.class {\\\\n color: red;\\\\n background: url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\");\\\\n}\\\\n\\\\n.class-duplicate-url {\\\\n background: url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\");\\\\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.class {\\\\n content: \\\\\\"\\\\\\\\2193\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2193\\\\\\\\2193\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2193 \\\\\\\\2193\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2193\\\\\\\\2193\\\\\\\\2193\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2193 \\\\\\\\2193 \\\\\\\\2193\\\\\\";\\\\n}\\\\n\\\\n.-top {}\\\\n.\\\\\\\\-top {}\\\\n\\\\n#\\\\\\\\#test {}\\\\n\\\\n.grid {\\\\n display: flex;\\\\n flex-wrap: wrap;\\\\n}\\\\n.grid.\\\\\\\\-top {\\\\n align-items: flex-start;\\\\n}\\\\n.grid.-top {\\\\n align-items: flex-start;\\\\n}\\\\n.grid.\\\\\\\\-middle {\\\\n align-items: center;\\\\n}\\\\n.grid.\\\\\\\\-bottom {\\\\n align-items: flex-end;\\\\n}\\\\n\\\\n.u-m\\\\\\\\00002b {}\\\\n\\\\n.u-m00002b {}\\\\n\\\\n#u-m\\\\\\\\+ {}\\\\n\\\\nbody {\\\\n font-family: '微软雅黑'; /* some chinese font name */\\\\n}\\\\n\\\\n.myStyle {\\\\n content: '\\\\\\\\e901';\\\\n}\\\\n\\\\n.myStyle {\\\\n content: '\\\\\\\\E901';\\\\n}\\\\n\\\\n.♫ {}\\\\n\\\\n.\\\\\\\\3A \\\\\\\\\`\\\\\\\\( {} /* matches elements with class=\\\\\\":\`(\\\\\\" */\\\\n.\\\\\\\\31 a2b3c {} /* matches elements with class=\\\\\\"1a2b3c\\\\\\" */\\\\n#\\\\\\\\#fake-id {} /* matches the element with id=\\\\\\"#fake-id\\\\\\" */\\\\n#-a-b-c- {} /* matches the element with id=\\\\\\"-a-b-c-\\\\\\" */\\\\n#© {} /* matches the element with id=\\\\\\"©\\\\\\" */\\\\n\\\\n:root {\\\\n --title-align: center;\\\\n --sr-only: {\\\\n position: absolute;\\\\n width: 1px;\\\\n height: 1px;\\\\n padding: 0;\\\\n overflow: hidden;\\\\n clip: rect(0,0,0,0);\\\\n white-space: nowrap;\\\\n clip-path: inset(50%);\\\\n border: 0;\\\\n };\\\\n}\\\\n\\\\n.test {\\\\n content: \\\\\\"\\\\\\\\2014\\\\\\\\A0\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2014 \\\\\\\\A0\\\\\\";\\\\n content: \\\\\\"\\\\\\\\A0 \\\\\\\\2014\\\\\\";\\\\n content: \\\\\\"\\\\\\\\A0\\\\\\\\2014\\\\\\";\\\\n margin-top: 1px\\\\\\\\9;\\\\n background-color: #000\\\\\\\\9;\\\\n}\\\\n\\\\n.light.on .bulb:before{\\\\n content: '💡';\\\\n}\\\\n\\\\n.base64 {\\\\n background: url(data:img/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAhxJREFUSA3tk71rU1EYxnMTEoJUkowWwdJ2akEHBfGjCiIF6ZylVUKSm2TqZLGI+A/oIu2UXm8C4lAyF4SWji0tdFLo1Eo7VN0SaBEhH7e/Nz0nPTfGOjiaCyfPc5734zlfCQT6X/8E/vUErL81KBaL9y3LSnued5PcITjUOwR3gsFg2bbtjYt6/NGgXC4P1et1l2aPLmpAbD0SidjpdPqgV15PA9d17zQajU8UxHQRK/4G35Q5pveAK8LlI1ZjPMnlcltnyvnvbwaO41xvtVqy7YHztMACq5xnlb9EY3dRdvcGo1kj5wR+t1AofDG0gM+A875E8DNjRCexsrV8Pj9ZqVQitVrtqejxePxjMpmss5hVTB4buXvMb2DyU2tBTRS+BjvNlVYUpPl7iuVO3Gq1uoQx1FtSOW1gPgp5ZWrdBtNmUDgv5asgxQ8F1af5vhY0YjyjuWC3wTszKJz7GBOkcFlQfW2ONq4FjWi+Hj6DRCKxQOK2TlY4x92EuYd5dvMAbYIzfikau3pu5tJ8KxaLLfo0cyKci7tK4TZjUMcoXAmHwzle0Q/RaC5P1GFMyVx9R9Fo9HYqlTrSgqDvFelAqVQa5hmuMR/WGtjAaBdjwBoDQ0ZsnwVMZjKZ9n0Zem8DSeDPdrnZbL6F2l3NOvUYNZk4oVDoRTabPe4EDNJzB0ZcjAYxeoZ2i3FNxQ7BHYw/cB/fldaH//UETgHHO8S44KbfXgAAAABJRU5ErkJggg==);\\\\n}\\\\n\\\\na[href=''] {\\\\n color: red;\\\\n}\\\\n\\\\na[href='' i] {\\\\n color: red;\\\\n}\\\\n\\\\na[href=\\\\\\"\\\\\\"] {\\\\n color: blue;\\\\n}\\\\n\\\\na[href=\\\\\\"\\\\\\" i] {\\\\n color: blue;\\\\n}\\\\n\\", \\"\\"]); -// Exports -module.exports = exports; -" -`; - -exports[`loader should work with "asset" module type: result 1`] = ` -Array [ - Array [ - "../../src/index.js!./imported.css", - ".foo { - color: red; -} -", - "", - ], - Array [ - "./basic.css", - "@charset \\"UTF-8\\"; - -/* Comment */ - -.class { - color: red; - background: url(/webpack/public/path/img.png); -} - -.class-duplicate-url { - background: url(/webpack/public/path/img.png); -} - -:root { - --foo: 1px; - --bar: 2px; -} - -.class { a: b c d; } - -.two {} - -.u-m\\\\+ { a: b c d; } - -.class { content: \\"\\\\F10C\\" } - -@media only screen and (max-width: 600px) { - body { - background-color: lightblue; - } -} - -.class { - content: \\"\\\\2193\\"; - content: \\"\\\\2193\\\\2193\\"; - content: \\"\\\\2193 \\\\2193\\"; - content: \\"\\\\2193\\\\2193\\\\2193\\"; - content: \\"\\\\2193 \\\\2193 \\\\2193\\"; -} - -.-top {} -.\\\\-top {} - -#\\\\#test {} - -.grid { - display: flex; - flex-wrap: wrap; -} -.grid.\\\\-top { - align-items: flex-start; -} -.grid.-top { - align-items: flex-start; -} -.grid.\\\\-middle { - align-items: center; -} -.grid.\\\\-bottom { - align-items: flex-end; -} - -.u-m\\\\00002b {} - -.u-m00002b {} - -#u-m\\\\+ {} - -body { - font-family: '微软雅黑'; /* some chinese font name */ -} - -.myStyle { - content: '\\\\e901'; -} - -.myStyle { - content: '\\\\E901'; -} - -.♫ {} - -.\\\\3A \\\\\`\\\\( {} /* matches elements with class=\\":\`(\\" */ -.\\\\31 a2b3c {} /* matches elements with class=\\"1a2b3c\\" */ -#\\\\#fake-id {} /* matches the element with id=\\"#fake-id\\" */ -#-a-b-c- {} /* matches the element with id=\\"-a-b-c-\\" */ -#© {} /* matches the element with id=\\"©\\" */ - -:root { - --title-align: center; - --sr-only: { - position: absolute; - width: 1px; - height: 1px; - padding: 0; - overflow: hidden; - clip: rect(0,0,0,0); - white-space: nowrap; - clip-path: inset(50%); - border: 0; - }; -} - -.test { - content: \\"\\\\2014\\\\A0\\"; - content: \\"\\\\2014 \\\\A0\\"; - content: \\"\\\\A0 \\\\2014\\"; - content: \\"\\\\A0\\\\2014\\"; - margin-top: 1px\\\\9; - background-color: #000\\\\9; -} - -.light.on .bulb:before{ - content: '💡'; -} - -.base64 { - background: url(data:img/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAhxJREFUSA3tk71rU1EYxnMTEoJUkowWwdJ2akEHBfGjCiIF6ZylVUKSm2TqZLGI+A/oIu2UXm8C4lAyF4SWji0tdFLo1Eo7VN0SaBEhH7e/Nz0nPTfGOjiaCyfPc5734zlfCQT6X/8E/vUErL81KBaL9y3LSnued5PcITjUOwR3gsFg2bbtjYt6/NGgXC4P1et1l2aPLmpAbD0SidjpdPqgV15PA9d17zQajU8UxHQRK/4G35Q5pveAK8LlI1ZjPMnlcltnyvnvbwaO41xvtVqy7YHztMACq5xnlb9EY3dRdvcGo1kj5wR+t1AofDG0gM+A875E8DNjRCexsrV8Pj9ZqVQitVrtqejxePxjMpmss5hVTB4buXvMb2DyU2tBTRS+BjvNlVYUpPl7iuVO3Gq1uoQx1FtSOW1gPgp5ZWrdBtNmUDgv5asgxQ8F1af5vhY0YjyjuWC3wTszKJz7GBOkcFlQfW2ONq4FjWi+Hj6DRCKxQOK2TlY4x92EuYd5dvMAbYIzfikau3pu5tJ8KxaLLfo0cyKci7tK4TZjUMcoXAmHwzle0Q/RaC5P1GFMyVx9R9Fo9HYqlTrSgqDvFelAqVQa5hmuMR/WGtjAaBdjwBoDQ0ZsnwVMZjKZ9n0Zem8DSeDPdrnZbL6F2l3NOvUYNZk4oVDoRTabPe4EDNJzB0ZcjAYxeoZ2i3FNxQ7BHYw/cB/fldaH//UETgHHO8S44KbfXgAAAABJRU5ErkJggg==); -} - -a[href=''] { - color: red; -} - -a[href='' i] { - color: red; -} - -a[href=\\"\\"] { - color: blue; -} - -a[href=\\"\\" i] { - color: blue; -} -", - "", - ], + "main.b38d5f87c88c55a4258e.bundle.js", ] `; -exports[`loader should work with "asset" module type: warnings 1`] = `Array []`; +exports[`loader should have same "contenthash" with "css-loader" and without source maps: warnings 1`] = `Array []`; -exports[`loader should work with "sass-loader": errors 1`] = `Array []`; +exports[`loader should have same "contenthash" with "postcss-loader" and with source maps: errors 1`] = `Array []`; -exports[`loader should work with "sass-loader": module 1`] = ` -"// Imports -var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../src/runtime/api.js\\"); -exports = ___CSS_LOADER_API_IMPORT___(false); -// Module -exports.push([module.id, \\"body {\\\\n font: 100% Helvetica, sans-serif;\\\\n color: #333;\\\\n}\\", \\"\\"]); -// Exports -module.exports = exports; -" -`; - -exports[`loader should work with "sass-loader": result 1`] = ` +exports[`loader should have same "contenthash" with "postcss-loader" and with source maps: module 1`] = ` Array [ - Array [ - "./scss/source.scss", - "body { - font: 100% Helvetica, sans-serif; - color: #333; -}", - "", - ], + "main.d77dd6564bc6e6297cd4.bundle.js", ] `; -exports[`loader should work with "sass-loader": warnings 1`] = `Array []`; - -exports[`loader should work with ModuleConcatenationPlugin (file-loader): errors 1`] = `Array []`; - -exports[`loader should work with ModuleConcatenationPlugin (file-loader): warnings 1`] = `Array []`; +exports[`loader should have same "contenthash" with "postcss-loader" and with source maps: warnings 1`] = `Array []`; -exports[`loader should work with ModuleConcatenationPlugin (url-loader): errors 1`] = `Array []`; +exports[`loader should have same "contenthash" with "postcss-loader" and without source maps: errors 1`] = `Array []`; -exports[`loader should work with ModuleConcatenationPlugin (url-loader): warnings 1`] = `Array []`; - -exports[`loader should work with ModuleConcatenationPlugin: errors 1`] = `Array []`; - -exports[`loader should work with ModuleConcatenationPlugin: warnings 1`] = `Array []`; - -exports[`loader should work with empty css: errors 1`] = `Array []`; - -exports[`loader should work with empty css: module 1`] = ` -"// Imports -var ___CSS_LOADER_API_IMPORT___ = require(\\"../../src/runtime/api.js\\"); -exports = ___CSS_LOADER_API_IMPORT___(false); -// Module -exports.push([module.id, \\"\\", \\"\\"]); -// Exports -module.exports = exports; -" -`; - -exports[`loader should work with empty css: result 1`] = ` +exports[`loader should have same "contenthash" with "postcss-loader" and without source maps: module 1`] = ` Array [ - Array [ - "./empty.css", - "", - "", - ], + "main.f8e62206a43c13393798.bundle.js", ] `; -exports[`loader should work with empty css: warnings 1`] = `Array []`; - -exports[`loader should work with empty options: errors 1`] = `Array []`; +exports[`loader should have same "contenthash" with "postcss-loader" and without source maps: warnings 1`] = `Array []`; -exports[`loader should work with empty options: module 1`] = ` -"// Imports -var ___CSS_LOADER_API_IMPORT___ = require(\\"../../src/runtime/api.js\\"); -var ___CSS_LOADER_AT_RULE_IMPORT_0___ = require(\\"-!../../src/index.js??[ident]!./imported.css\\"); -var ___CSS_LOADER_GET_URL_IMPORT___ = require(\\"../../src/runtime/getUrl.js\\"); -var ___CSS_LOADER_URL_IMPORT_0___ = require(\\"./url/img.png\\"); -exports = ___CSS_LOADER_API_IMPORT___(false); -exports.i(___CSS_LOADER_AT_RULE_IMPORT_0___); -var ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___); -// Module -exports.push([module.id, \\"@charset \\\\\\"UTF-8\\\\\\";\\\\n\\\\n/* Comment */\\\\n\\\\n.class {\\\\n color: red;\\\\n background: url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\");\\\\n}\\\\n\\\\n.class-duplicate-url {\\\\n background: url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\");\\\\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.class {\\\\n content: \\\\\\"\\\\\\\\2193\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2193\\\\\\\\2193\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2193 \\\\\\\\2193\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2193\\\\\\\\2193\\\\\\\\2193\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2193 \\\\\\\\2193 \\\\\\\\2193\\\\\\";\\\\n}\\\\n\\\\n.-top {}\\\\n.\\\\\\\\-top {}\\\\n\\\\n#\\\\\\\\#test {}\\\\n\\\\n.grid {\\\\n display: flex;\\\\n flex-wrap: wrap;\\\\n}\\\\n.grid.\\\\\\\\-top {\\\\n align-items: flex-start;\\\\n}\\\\n.grid.-top {\\\\n align-items: flex-start;\\\\n}\\\\n.grid.\\\\\\\\-middle {\\\\n align-items: center;\\\\n}\\\\n.grid.\\\\\\\\-bottom {\\\\n align-items: flex-end;\\\\n}\\\\n\\\\n.u-m\\\\\\\\00002b {}\\\\n\\\\n.u-m00002b {}\\\\n\\\\n#u-m\\\\\\\\+ {}\\\\n\\\\nbody {\\\\n font-family: '微软雅黑'; /* some chinese font name */\\\\n}\\\\n\\\\n.myStyle {\\\\n content: '\\\\\\\\e901';\\\\n}\\\\n\\\\n.myStyle {\\\\n content: '\\\\\\\\E901';\\\\n}\\\\n\\\\n.♫ {}\\\\n\\\\n.\\\\\\\\3A \\\\\\\\\`\\\\\\\\( {} /* matches elements with class=\\\\\\":\`(\\\\\\" */\\\\n.\\\\\\\\31 a2b3c {} /* matches elements with class=\\\\\\"1a2b3c\\\\\\" */\\\\n#\\\\\\\\#fake-id {} /* matches the element with id=\\\\\\"#fake-id\\\\\\" */\\\\n#-a-b-c- {} /* matches the element with id=\\\\\\"-a-b-c-\\\\\\" */\\\\n#© {} /* matches the element with id=\\\\\\"©\\\\\\" */\\\\n\\\\n:root {\\\\n --title-align: center;\\\\n --sr-only: {\\\\n position: absolute;\\\\n width: 1px;\\\\n height: 1px;\\\\n padding: 0;\\\\n overflow: hidden;\\\\n clip: rect(0,0,0,0);\\\\n white-space: nowrap;\\\\n clip-path: inset(50%);\\\\n border: 0;\\\\n };\\\\n}\\\\n\\\\n.test {\\\\n content: \\\\\\"\\\\\\\\2014\\\\\\\\A0\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2014 \\\\\\\\A0\\\\\\";\\\\n content: \\\\\\"\\\\\\\\A0 \\\\\\\\2014\\\\\\";\\\\n content: \\\\\\"\\\\\\\\A0\\\\\\\\2014\\\\\\";\\\\n margin-top: 1px\\\\\\\\9;\\\\n background-color: #000\\\\\\\\9;\\\\n}\\\\n\\\\n.light.on .bulb:before{\\\\n content: '💡';\\\\n}\\\\n\\\\n.base64 {\\\\n background: url(data:img/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAhxJREFUSA3tk71rU1EYxnMTEoJUkowWwdJ2akEHBfGjCiIF6ZylVUKSm2TqZLGI+A/oIu2UXm8C4lAyF4SWji0tdFLo1Eo7VN0SaBEhH7e/Nz0nPTfGOjiaCyfPc5734zlfCQT6X/8E/vUErL81KBaL9y3LSnued5PcITjUOwR3gsFg2bbtjYt6/NGgXC4P1et1l2aPLmpAbD0SidjpdPqgV15PA9d17zQajU8UxHQRK/4G35Q5pveAK8LlI1ZjPMnlcltnyvnvbwaO41xvtVqy7YHztMACq5xnlb9EY3dRdvcGo1kj5wR+t1AofDG0gM+A875E8DNjRCexsrV8Pj9ZqVQitVrtqejxePxjMpmss5hVTB4buXvMb2DyU2tBTRS+BjvNlVYUpPl7iuVO3Gq1uoQx1FtSOW1gPgp5ZWrdBtNmUDgv5asgxQ8F1af5vhY0YjyjuWC3wTszKJz7GBOkcFlQfW2ONq4FjWi+Hj6DRCKxQOK2TlY4x92EuYd5dvMAbYIzfikau3pu5tJ8KxaLLfo0cyKci7tK4TZjUMcoXAmHwzle0Q/RaC5P1GFMyVx9R9Fo9HYqlTrSgqDvFelAqVQa5hmuMR/WGtjAaBdjwBoDQ0ZsnwVMZjKZ9n0Zem8DSeDPdrnZbL6F2l3NOvUYNZk4oVDoRTabPe4EDNJzB0ZcjAYxeoZ2i3FNxQ7BHYw/cB/fldaH//UETgHHO8S44KbfXgAAAABJRU5ErkJggg==);\\\\n}\\\\n\\\\na[href=''] {\\\\n color: red;\\\\n}\\\\n\\\\na[href='' i] {\\\\n color: red;\\\\n}\\\\n\\\\na[href=\\\\\\"\\\\\\"] {\\\\n color: blue;\\\\n}\\\\n\\\\na[href=\\\\\\"\\\\\\" i] {\\\\n color: blue;\\\\n}\\\\n\\", \\"\\"]); -// Exports -module.exports = exports; -" -`; +exports[`loader should have same "contenthash" with "sass-loader" and with source maps: errors 1`] = `Array []`; -exports[`loader should work with empty options: result 1`] = ` +exports[`loader should have same "contenthash" with "sass-loader" and with source maps: module 1`] = ` Array [ - Array [ - "../../src/index.js?[ident]!./imported.css", - ".foo { - color: red; -} -", - "", - ], - Array [ - "./basic.css", - "@charset \\"UTF-8\\"; - -/* Comment */ - -.class { - color: red; - background: url(/webpack/public/path/img.png); -} - -.class-duplicate-url { - background: url(/webpack/public/path/img.png); -} - -:root { - --foo: 1px; - --bar: 2px; -} - -.class { a: b c d; } - -.two {} - -.u-m\\\\+ { a: b c d; } - -.class { content: \\"\\\\F10C\\" } - -@media only screen and (max-width: 600px) { - body { - background-color: lightblue; - } -} - -.class { - content: \\"\\\\2193\\"; - content: \\"\\\\2193\\\\2193\\"; - content: \\"\\\\2193 \\\\2193\\"; - content: \\"\\\\2193\\\\2193\\\\2193\\"; - content: \\"\\\\2193 \\\\2193 \\\\2193\\"; -} - -.-top {} -.\\\\-top {} - -#\\\\#test {} - -.grid { - display: flex; - flex-wrap: wrap; -} -.grid.\\\\-top { - align-items: flex-start; -} -.grid.-top { - align-items: flex-start; -} -.grid.\\\\-middle { - align-items: center; -} -.grid.\\\\-bottom { - align-items: flex-end; -} - -.u-m\\\\00002b {} - -.u-m00002b {} - -#u-m\\\\+ {} - -body { - font-family: '微软雅黑'; /* some chinese font name */ -} - -.myStyle { - content: '\\\\e901'; -} - -.myStyle { - content: '\\\\E901'; -} - -.♫ {} - -.\\\\3A \\\\\`\\\\( {} /* matches elements with class=\\":\`(\\" */ -.\\\\31 a2b3c {} /* matches elements with class=\\"1a2b3c\\" */ -#\\\\#fake-id {} /* matches the element with id=\\"#fake-id\\" */ -#-a-b-c- {} /* matches the element with id=\\"-a-b-c-\\" */ -#© {} /* matches the element with id=\\"©\\" */ - -:root { - --title-align: center; - --sr-only: { - position: absolute; - width: 1px; - height: 1px; - padding: 0; - overflow: hidden; - clip: rect(0,0,0,0); - white-space: nowrap; - clip-path: inset(50%); - border: 0; - }; -} - -.test { - content: \\"\\\\2014\\\\A0\\"; - content: \\"\\\\2014 \\\\A0\\"; - content: \\"\\\\A0 \\\\2014\\"; - content: \\"\\\\A0\\\\2014\\"; - margin-top: 1px\\\\9; - background-color: #000\\\\9; -} - -.light.on .bulb:before{ - content: '💡'; -} - -.base64 { - background: url(data:img/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAhxJREFUSA3tk71rU1EYxnMTEoJUkowWwdJ2akEHBfGjCiIF6ZylVUKSm2TqZLGI+A/oIu2UXm8C4lAyF4SWji0tdFLo1Eo7VN0SaBEhH7e/Nz0nPTfGOjiaCyfPc5734zlfCQT6X/8E/vUErL81KBaL9y3LSnued5PcITjUOwR3gsFg2bbtjYt6/NGgXC4P1et1l2aPLmpAbD0SidjpdPqgV15PA9d17zQajU8UxHQRK/4G35Q5pveAK8LlI1ZjPMnlcltnyvnvbwaO41xvtVqy7YHztMACq5xnlb9EY3dRdvcGo1kj5wR+t1AofDG0gM+A875E8DNjRCexsrV8Pj9ZqVQitVrtqejxePxjMpmss5hVTB4buXvMb2DyU2tBTRS+BjvNlVYUpPl7iuVO3Gq1uoQx1FtSOW1gPgp5ZWrdBtNmUDgv5asgxQ8F1af5vhY0YjyjuWC3wTszKJz7GBOkcFlQfW2ONq4FjWi+Hj6DRCKxQOK2TlY4x92EuYd5dvMAbYIzfikau3pu5tJ8KxaLLfo0cyKci7tK4TZjUMcoXAmHwzle0Q/RaC5P1GFMyVx9R9Fo9HYqlTrSgqDvFelAqVQa5hmuMR/WGtjAaBdjwBoDQ0ZsnwVMZjKZ9n0Zem8DSeDPdrnZbL6F2l3NOvUYNZk4oVDoRTabPe4EDNJzB0ZcjAYxeoZ2i3FNxQ7BHYw/cB/fldaH//UETgHHO8S44KbfXgAAAABJRU5ErkJggg==); -} - -a[href=''] { - color: red; -} - -a[href='' i] { - color: red; -} - -a[href=\\"\\"] { - color: blue; -} - -a[href=\\"\\" i] { - color: blue; -} -", - "", - ], + "main.151589c7e12ebfd445e7.bundle.js", ] `; -exports[`loader should work with empty options: warnings 1`] = `Array []`; - -exports[`loader should work: errors 1`] = `Array []`; +exports[`loader should have same "contenthash" with "sass-loader" and with source maps: warnings 1`] = `Array []`; -exports[`loader should work: module 1`] = ` -"// Imports -var ___CSS_LOADER_API_IMPORT___ = require(\\"../../src/runtime/api.js\\"); -var ___CSS_LOADER_AT_RULE_IMPORT_0___ = require(\\"-!../../src/index.js??[ident]!./imported.css\\"); -var ___CSS_LOADER_GET_URL_IMPORT___ = require(\\"../../src/runtime/getUrl.js\\"); -var ___CSS_LOADER_URL_IMPORT_0___ = require(\\"./url/img.png\\"); -exports = ___CSS_LOADER_API_IMPORT___(false); -exports.i(___CSS_LOADER_AT_RULE_IMPORT_0___); -var ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___); -// Module -exports.push([module.id, \\"@charset \\\\\\"UTF-8\\\\\\";\\\\n\\\\n/* Comment */\\\\n\\\\n.class {\\\\n color: red;\\\\n background: url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\");\\\\n}\\\\n\\\\n.class-duplicate-url {\\\\n background: url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\");\\\\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.class {\\\\n content: \\\\\\"\\\\\\\\2193\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2193\\\\\\\\2193\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2193 \\\\\\\\2193\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2193\\\\\\\\2193\\\\\\\\2193\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2193 \\\\\\\\2193 \\\\\\\\2193\\\\\\";\\\\n}\\\\n\\\\n.-top {}\\\\n.\\\\\\\\-top {}\\\\n\\\\n#\\\\\\\\#test {}\\\\n\\\\n.grid {\\\\n display: flex;\\\\n flex-wrap: wrap;\\\\n}\\\\n.grid.\\\\\\\\-top {\\\\n align-items: flex-start;\\\\n}\\\\n.grid.-top {\\\\n align-items: flex-start;\\\\n}\\\\n.grid.\\\\\\\\-middle {\\\\n align-items: center;\\\\n}\\\\n.grid.\\\\\\\\-bottom {\\\\n align-items: flex-end;\\\\n}\\\\n\\\\n.u-m\\\\\\\\00002b {}\\\\n\\\\n.u-m00002b {}\\\\n\\\\n#u-m\\\\\\\\+ {}\\\\n\\\\nbody {\\\\n font-family: '微软雅黑'; /* some chinese font name */\\\\n}\\\\n\\\\n.myStyle {\\\\n content: '\\\\\\\\e901';\\\\n}\\\\n\\\\n.myStyle {\\\\n content: '\\\\\\\\E901';\\\\n}\\\\n\\\\n.♫ {}\\\\n\\\\n.\\\\\\\\3A \\\\\\\\\`\\\\\\\\( {} /* matches elements with class=\\\\\\":\`(\\\\\\" */\\\\n.\\\\\\\\31 a2b3c {} /* matches elements with class=\\\\\\"1a2b3c\\\\\\" */\\\\n#\\\\\\\\#fake-id {} /* matches the element with id=\\\\\\"#fake-id\\\\\\" */\\\\n#-a-b-c- {} /* matches the element with id=\\\\\\"-a-b-c-\\\\\\" */\\\\n#© {} /* matches the element with id=\\\\\\"©\\\\\\" */\\\\n\\\\n:root {\\\\n --title-align: center;\\\\n --sr-only: {\\\\n position: absolute;\\\\n width: 1px;\\\\n height: 1px;\\\\n padding: 0;\\\\n overflow: hidden;\\\\n clip: rect(0,0,0,0);\\\\n white-space: nowrap;\\\\n clip-path: inset(50%);\\\\n border: 0;\\\\n };\\\\n}\\\\n\\\\n.test {\\\\n content: \\\\\\"\\\\\\\\2014\\\\\\\\A0\\\\\\";\\\\n content: \\\\\\"\\\\\\\\2014 \\\\\\\\A0\\\\\\";\\\\n content: \\\\\\"\\\\\\\\A0 \\\\\\\\2014\\\\\\";\\\\n content: \\\\\\"\\\\\\\\A0\\\\\\\\2014\\\\\\";\\\\n margin-top: 1px\\\\\\\\9;\\\\n background-color: #000\\\\\\\\9;\\\\n}\\\\n\\\\n.light.on .bulb:before{\\\\n content: '💡';\\\\n}\\\\n\\\\n.base64 {\\\\n background: url(data:img/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAhxJREFUSA3tk71rU1EYxnMTEoJUkowWwdJ2akEHBfGjCiIF6ZylVUKSm2TqZLGI+A/oIu2UXm8C4lAyF4SWji0tdFLo1Eo7VN0SaBEhH7e/Nz0nPTfGOjiaCyfPc5734zlfCQT6X/8E/vUErL81KBaL9y3LSnued5PcITjUOwR3gsFg2bbtjYt6/NGgXC4P1et1l2aPLmpAbD0SidjpdPqgV15PA9d17zQajU8UxHQRK/4G35Q5pveAK8LlI1ZjPMnlcltnyvnvbwaO41xvtVqy7YHztMACq5xnlb9EY3dRdvcGo1kj5wR+t1AofDG0gM+A875E8DNjRCexsrV8Pj9ZqVQitVrtqejxePxjMpmss5hVTB4buXvMb2DyU2tBTRS+BjvNlVYUpPl7iuVO3Gq1uoQx1FtSOW1gPgp5ZWrdBtNmUDgv5asgxQ8F1af5vhY0YjyjuWC3wTszKJz7GBOkcFlQfW2ONq4FjWi+Hj6DRCKxQOK2TlY4x92EuYd5dvMAbYIzfikau3pu5tJ8KxaLLfo0cyKci7tK4TZjUMcoXAmHwzle0Q/RaC5P1GFMyVx9R9Fo9HYqlTrSgqDvFelAqVQa5hmuMR/WGtjAaBdjwBoDQ0ZsnwVMZjKZ9n0Zem8DSeDPdrnZbL6F2l3NOvUYNZk4oVDoRTabPe4EDNJzB0ZcjAYxeoZ2i3FNxQ7BHYw/cB/fldaH//UETgHHO8S44KbfXgAAAABJRU5ErkJggg==);\\\\n}\\\\n\\\\na[href=''] {\\\\n color: red;\\\\n}\\\\n\\\\na[href='' i] {\\\\n color: red;\\\\n}\\\\n\\\\na[href=\\\\\\"\\\\\\"] {\\\\n color: blue;\\\\n}\\\\n\\\\na[href=\\\\\\"\\\\\\" i] {\\\\n color: blue;\\\\n}\\\\n\\", \\"\\"]); -// Exports -module.exports = exports; -" -`; +exports[`loader should have same "contenthash" with "sass-loader" and without source maps: errors 1`] = `Array []`; -exports[`loader should work: result 1`] = ` +exports[`loader should have same "contenthash" with "sass-loader" and without source maps: module 1`] = ` Array [ - Array [ - "../../src/index.js?[ident]!./imported.css", - ".foo { - color: red; -} -", - "", - ], - Array [ - "./basic.css", - "@charset \\"UTF-8\\"; - -/* Comment */ - -.class { - color: red; - background: url(/webpack/public/path/img.png); -} - -.class-duplicate-url { - background: url(/webpack/public/path/img.png); -} - -:root { - --foo: 1px; - --bar: 2px; -} - -.class { a: b c d; } - -.two {} - -.u-m\\\\+ { a: b c d; } - -.class { content: \\"\\\\F10C\\" } - -@media only screen and (max-width: 600px) { - body { - background-color: lightblue; - } -} - -.class { - content: \\"\\\\2193\\"; - content: \\"\\\\2193\\\\2193\\"; - content: \\"\\\\2193 \\\\2193\\"; - content: \\"\\\\2193\\\\2193\\\\2193\\"; - content: \\"\\\\2193 \\\\2193 \\\\2193\\"; -} - -.-top {} -.\\\\-top {} - -#\\\\#test {} - -.grid { - display: flex; - flex-wrap: wrap; -} -.grid.\\\\-top { - align-items: flex-start; -} -.grid.-top { - align-items: flex-start; -} -.grid.\\\\-middle { - align-items: center; -} -.grid.\\\\-bottom { - align-items: flex-end; -} - -.u-m\\\\00002b {} - -.u-m00002b {} - -#u-m\\\\+ {} - -body { - font-family: '微软雅黑'; /* some chinese font name */ -} - -.myStyle { - content: '\\\\e901'; -} - -.myStyle { - content: '\\\\E901'; -} - -.♫ {} - -.\\\\3A \\\\\`\\\\( {} /* matches elements with class=\\":\`(\\" */ -.\\\\31 a2b3c {} /* matches elements with class=\\"1a2b3c\\" */ -#\\\\#fake-id {} /* matches the element with id=\\"#fake-id\\" */ -#-a-b-c- {} /* matches the element with id=\\"-a-b-c-\\" */ -#© {} /* matches the element with id=\\"©\\" */ - -:root { - --title-align: center; - --sr-only: { - position: absolute; - width: 1px; - height: 1px; - padding: 0; - overflow: hidden; - clip: rect(0,0,0,0); - white-space: nowrap; - clip-path: inset(50%); - border: 0; - }; -} - -.test { - content: \\"\\\\2014\\\\A0\\"; - content: \\"\\\\2014 \\\\A0\\"; - content: \\"\\\\A0 \\\\2014\\"; - content: \\"\\\\A0\\\\2014\\"; - margin-top: 1px\\\\9; - background-color: #000\\\\9; -} - -.light.on .bulb:before{ - content: '💡'; -} - -.base64 { - background: url(data:img/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAhxJREFUSA3tk71rU1EYxnMTEoJUkowWwdJ2akEHBfGjCiIF6ZylVUKSm2TqZLGI+A/oIu2UXm8C4lAyF4SWji0tdFLo1Eo7VN0SaBEhH7e/Nz0nPTfGOjiaCyfPc5734zlfCQT6X/8E/vUErL81KBaL9y3LSnued5PcITjUOwR3gsFg2bbtjYt6/NGgXC4P1et1l2aPLmpAbD0SidjpdPqgV15PA9d17zQajU8UxHQRK/4G35Q5pveAK8LlI1ZjPMnlcltnyvnvbwaO41xvtVqy7YHztMACq5xnlb9EY3dRdvcGo1kj5wR+t1AofDG0gM+A875E8DNjRCexsrV8Pj9ZqVQitVrtqejxePxjMpmss5hVTB4buXvMb2DyU2tBTRS+BjvNlVYUpPl7iuVO3Gq1uoQx1FtSOW1gPgp5ZWrdBtNmUDgv5asgxQ8F1af5vhY0YjyjuWC3wTszKJz7GBOkcFlQfW2ONq4FjWi+Hj6DRCKxQOK2TlY4x92EuYd5dvMAbYIzfikau3pu5tJ8KxaLLfo0cyKci7tK4TZjUMcoXAmHwzle0Q/RaC5P1GFMyVx9R9Fo9HYqlTrSgqDvFelAqVQa5hmuMR/WGtjAaBdjwBoDQ0ZsnwVMZjKZ9n0Zem8DSeDPdrnZbL6F2l3NOvUYNZk4oVDoRTabPe4EDNJzB0ZcjAYxeoZ2i3FNxQ7BHYw/cB/fldaH//UETgHHO8S44KbfXgAAAABJRU5ErkJggg==); -} - -a[href=''] { - color: red; -} - -a[href='' i] { - color: red; -} - -a[href=\\"\\"] { - color: blue; -} - -a[href=\\"\\" i] { - color: blue; -} -", - "", - ], + "main.9ae036ace8bbbebbd185.bundle.js", ] `; -exports[`loader should work: warnings 1`] = `Array []`; +exports[`loader should have same "contenthash" with "sass-loader" and without source maps: warnings 1`] = `Array []`; diff --git a/test/loader.test.js b/test/loader.test.js index 2da97263..5ce9522b 100644 --- a/test/loader.test.js +++ b/test/loader.test.js @@ -309,7 +309,40 @@ describe('loader', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should have same "contenthash" with "css-loader" and source maps', async () => { + it.only('should have same "contenthash" with "css-loader" and without source maps', async () => { + const compiler = getCompiler( + './contenthash/basic-css.js', + {}, + { + output: { + path: path.resolve(__dirname, '../outputs'), + filename: '[name].[contenthash].bundle.js', + chunkFilename: '[name].[contenthash].chunk.js', + publicPath: '/webpack/public/path/', + }, + module: { + rules: [ + { + test: /\.css$/i, + rules: [ + { + loader: path.resolve(__dirname, '../src'), + options: { sourceMap: false }, + }, + ], + }, + ], + }, + } + ); + const stats = await compile(compiler); + + expect(Object.keys(stats.compilation.assets)).toMatchSnapshot('module'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + }); + + it.only('should have same "contenthash" with "css-loader" and with source maps', async () => { const compiler = getCompiler( './contenthash/basic-css.js', {}, @@ -342,7 +375,50 @@ describe('loader', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should have same "contenthash" with "postcss-loader" and source maps', async () => { + it.only('should have same "contenthash" with "postcss-loader" and without source maps', async () => { + const compiler = getCompiler( + './contenthash/basic-postcss.js', + {}, + { + output: { + path: path.resolve(__dirname, '../outputs'), + filename: '[name].[contenthash].bundle.js', + chunkFilename: '[name].[contenthash].chunk.js', + publicPath: '/webpack/public/path/', + }, + module: { + rules: [ + { + test: /\.css$/i, + rules: [ + { + loader: path.resolve(__dirname, '../src'), + options: { + sourceMap: false, + importLoaders: 1, + }, + }, + { + loader: 'postcss-loader', + options: { + plugins: () => [postcssPresetEnv({ stage: 0 })], + sourceMap: false, + }, + }, + ], + }, + ], + }, + } + ); + const stats = await compile(compiler); + + expect(Object.keys(stats.compilation.assets)).toMatchSnapshot('module'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + }); + + it.only('should have same "contenthash" with "postcss-loader" and with source maps', async () => { const compiler = getCompiler( './contenthash/basic-postcss.js', {}, @@ -385,7 +461,58 @@ describe('loader', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should have same "contenthash" with "sass-loader" and source maps', async () => { + it.only('should have same "contenthash" with "sass-loader" and without source maps', async () => { + const compiler = getCompiler( + './contenthash/basic-sass.js', + {}, + { + output: { + path: path.resolve(__dirname, '../outputs'), + filename: '[name].[contenthash].bundle.js', + chunkFilename: '[name].[contenthash].chunk.js', + publicPath: '/webpack/public/path/', + }, + module: { + rules: [ + { + test: /\.s[ca]ss$/i, + rules: [ + { + loader: path.resolve(__dirname, '../src'), + options: { + sourceMap: false, + importLoaders: 1, + }, + }, + { + loader: 'postcss-loader', + options: { + plugins: () => [postcssPresetEnv({ stage: 0 })], + sourceMap: false, + }, + }, + { + loader: 'sass-loader', + options: { + // eslint-disable-next-line global-require + implementation: require('sass'), + sourceMap: false, + }, + }, + ], + }, + ], + }, + } + ); + const stats = await compile(compiler); + + expect(Object.keys(stats.compilation.assets)).toMatchSnapshot('module'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + }); + + it.only('should have same "contenthash" with "sass-loader" and with source maps', async () => { const compiler = getCompiler( './contenthash/basic-sass.js', {}, @@ -431,8 +558,6 @@ describe('loader', () => { ); const stats = await compile(compiler); - console.log(stats.compilation.assets); - expect(Object.keys(stats.compilation.assets)).toMatchSnapshot('module'); expect(getWarnings(stats)).toMatchSnapshot('warnings'); expect(getErrors(stats)).toMatchSnapshot('errors');