diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a5afa07..5427273f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [0.28.10](https://github.com/webpack-contrib/css-loader/compare/v0.28.9...v0.28.10) (2018-02-22) + + +### Bug Fixes + +* **getLocalIdent:** add `rootContext` support (`webpack >= v4.0.0`) ([#681](https://github.com/webpack-contrib/css-loader/issues/681)) ([9f876d2](https://github.com/webpack-contrib/css-loader/commit/9f876d2)) + + + ## [0.28.9](https://github.com/webpack-contrib/css-loader/compare/v0.28.8...v0.28.9) (2018-01-17) diff --git a/lib/getLocalIdent.js b/lib/getLocalIdent.js index d671fb64..79c7ab57 100644 --- a/lib/getLocalIdent.js +++ b/lib/getLocalIdent.js @@ -6,8 +6,15 @@ var loaderUtils = require("loader-utils"); var path = require("path"); module.exports = function getLocalIdent(loaderContext, localIdentName, localName, options) { - if(!options.context) - options.context = loaderContext.options && typeof loaderContext.options.context === "string" ? loaderContext.options.context : loaderContext.context; + if(!options.context) { + if (loaderContext.rootContext) { + options.context = loaderContext.rootContext; + } else if (loaderContext.options && typeof loaderContext.options.context === "string") { + options.context = loaderContext.options.context; + } else { + options.context = loaderContext.context; + } + } var request = path.relative(options.context, loaderContext.resourcePath); options.content = options.hashPrefix + request + "+" + localName; localIdentName = localIdentName.replace(/\[local\]/gi, localName); diff --git a/package-lock.json b/package-lock.json index 363c1933..22b0f5ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "css-loader", - "version": "0.28.9", + "version": "0.28.10", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c29a246a..8fd72c31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "css-loader", - "version": "0.28.9", + "version": "0.28.10", "author": "Tobias Koppers @sokra", "license": "MIT", "description": "css loader module for webpack", diff --git a/test/urlTest.js b/test/urlTest.js index 543a47fe..9b6b0d22 100644 --- a/test/urlTest.js +++ b/test/urlTest.js @@ -184,6 +184,12 @@ describe("url", function() { test("font face with url", "@font-face { src: url(regular.woff) format('woff'), url(~truetype/regular.ttf) format('truetype') }", [ [1, "@font-face { src: url(regular.woff) format('woff'), url(~truetype/regular.ttf) format('truetype') }", ""] ], "?-url"); + test("font face with url", "@font-face { src: url(Mark Simonson - Proxima Nova Alt Regular-webfont.eot?#iefix) format('embedded-opentype'), url(~opentype/Mark Simonson - Proxima Nova Alt Regular-webfont.eot?#iefix) format('embedded-opentype') }", [ + [1, "@font-face { src: url(Mark Simonson - Proxima Nova Alt Regular-webfont.eot?#iefix) format('embedded-opentype'), url(~opentype/Mark Simonson - Proxima Nova Alt Regular-webfont.eot?#iefix) format('embedded-opentype') }", ""] + ], "?-url"); + test("font face with url", "@font-face { src: url('Mark Simonson - Proxima Nova Alt Regular-webfont.eot?#iefix') format('embedded-opentype'), url(\"Mark Simonson - Proxima Nova Alt Regular-webfont.eot?#iefix\") format('embedded-opentype') }", [ + [1, "@font-face { src: url('Mark Simonson - Proxima Nova Alt Regular-webfont.eot?#iefix') format('embedded-opentype'), url(\"Mark Simonson - Proxima Nova Alt Regular-webfont.eot?#iefix\") format('embedded-opentype') }", ""] + ], "?-url"); test("media query with url", "@media (min-width: 500px) { body { background: url(image.png); } }", [ [1, "@media (min-width: 500px) { body { background: url(image.png); } }", ""] ], "?-url");