diff --git a/README.md b/README.md
index aac1d972..368dd5ee 100644
--- a/README.md
+++ b/README.md
@@ -82,8 +82,6 @@ import url from 'file.css';
```
-> ℹ️ Source maps and assets referenced with `url`: when style loader is used with `{ options: { sourceMap: true } }` option, the CSS modules will be generated as `Blob`s, so relative paths don't work (they would be relative to `chrome:blob` or `chrome:devtools`). In order for assets to maintain correct paths setting `output.publicPath` property of webpack configuration must be set, so that absolute paths are generated. Alternatively you can enable the `convertToAbsoluteUrls` option mentioned above.
-
### `Useable`
The `style-loader` injects the styles lazily making them useable on-demand via `style.use()` / `style.unuse()`
@@ -145,7 +143,6 @@ Styles are not added on `import/require()`, but instead on call to `use`/`ref`.
| **`insertInto`** | `{String\|Function}` | `
` | Inserts `` into the given position |
| **`singleton`** | `{Boolean}` | `undefined` | Reuses a single `` element, instead of adding/removing individual elements for each required module. |
| **`sourceMap`** | `{Boolean}` | `false` | Enable/Disable Sourcemaps |
-| **`convertToAbsoluteUrls`** | `{Boolean}` | `false` | Converts relative URLs to absolute urls, when source maps are enabled |
### `hmr`
@@ -397,22 +394,6 @@ Enable/Disable source map loading
}
```
-### `convertToAbsoluteUrls`
-
-If convertToAbsoluteUrls and sourceMaps are both enabled, relative urls will be converted to absolute urls right before the css is injected into the page. This resolves [an issue](https://github.com/webpack/style-loader/pull/96) where relative resources fail to load when source maps are enabled. You can enable it with the convertToAbsoluteUrls option.
-
-**webpack.config.js**
-
-```js
-{
- loader: 'style-loader',
- options: {
- sourceMap: true,
- convertToAbsoluteUrls: true
- }
-}
-```
-
Maintainers
diff --git a/package-lock.json b/package-lock.json
index a017bed2..7b259bdb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -693,16 +693,6 @@
"regexpu-core": "^4.1.3"
}
},
- "@babel/polyfill": {
- "version": "7.4.0",
- "resolved": "https://registry.npmjs.org/@babel/polyfill/-/polyfill-7.4.0.tgz",
- "integrity": "sha512-bVsjsrtsDflIHp5I6caaAa2V25Kzn50HKPL6g3X0P0ni1ks+58cPB8Mz6AOKVuRPgaVdq/OwEUc/1vKqX+Mo4A==",
- "dev": true,
- "requires": {
- "core-js": "^2.6.5",
- "regenerator-runtime": "^0.13.2"
- }
- },
"@babel/preset-env": {
"version": "7.4.2",
"resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.4.2.tgz",
@@ -823,22 +813,22 @@
}
},
"@commitlint/cli": {
- "version": "7.5.2",
- "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-7.5.2.tgz",
- "integrity": "sha512-UQdW/wNb+XeANoYYLyuKEDIfWKSzdhJkPQZ8ie/IjfMNnsP+B23bkX4Ati+6U8zgz0yyngoxWl+3lfExiIL4hQ==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-8.1.0.tgz",
+ "integrity": "sha512-83K5C2nIAgoZlzMegf0/MEBjX+ampUyc/u79RxgX9ZYjzos+RQtNyO7I43dztVxPXSwAnX9XRgoOfkGWA4nbig==",
"dev": true,
"requires": {
- "@commitlint/format": "^7.5.0",
- "@commitlint/lint": "^7.5.2",
- "@commitlint/load": "^7.5.0",
- "@commitlint/read": "^7.5.0",
+ "@commitlint/format": "^8.1.0",
+ "@commitlint/lint": "^8.1.0",
+ "@commitlint/load": "^8.1.0",
+ "@commitlint/read": "^8.1.0",
"babel-polyfill": "6.26.0",
"chalk": "2.3.1",
- "get-stdin": "5.0.1",
- "lodash": "4.17.11",
+ "get-stdin": "7.0.0",
+ "lodash": "4.17.14",
"meow": "5.0.0",
- "resolve-from": "4.0.0",
- "resolve-global": "0.1.0"
+ "resolve-from": "5.0.0",
+ "resolve-global": "1.0.0"
},
"dependencies": {
"camelcase": {
@@ -868,9 +858,9 @@
}
},
"get-stdin": {
- "version": "5.0.1",
- "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz",
- "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=",
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-7.0.0.tgz",
+ "integrity": "sha512-zRKcywvrXlXsA0v0i9Io4KDRaAw7+a1ZpjRwl9Wox8PFlVCCHra7E9c4kqXCoCM9nR5tBkaTTZRBoCm60bFqTQ==",
"dev": true
},
"locate-path": {
@@ -883,6 +873,12 @@
"path-exists": "^3.0.0"
}
},
+ "lodash": {
+ "version": "4.17.14",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz",
+ "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==",
+ "dev": true
+ },
"meow": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/meow/-/meow-5.0.0.tgz",
@@ -935,9 +931,9 @@
}
},
"resolve-from": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
- "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
+ "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
"dev": true
},
"yargs-parser": {
@@ -958,87 +954,115 @@
"dev": true
},
"@commitlint/ensure": {
- "version": "7.5.2",
- "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-7.5.2.tgz",
- "integrity": "sha512-ZMJKHhSJC789chKy0kWp8EWbCpLPy6vKa+fopUVx+tWL7H8AeBbibXlqAnybg+HWNcb/RD7ORROx0IsgrK4IYA==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-8.1.0.tgz",
+ "integrity": "sha512-dBU4CcjN0vJSDNOeSpaHNgQ1ra444u4USvI6PTaHVAS4aeDpZ5Cds1rxkZNsocu48WNycUu0jP84+zjcw2pPLQ==",
"dev": true,
"requires": {
- "lodash": "4.17.11"
+ "lodash": "4.17.14"
+ },
+ "dependencies": {
+ "lodash": {
+ "version": "4.17.14",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz",
+ "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==",
+ "dev": true
+ }
}
},
"@commitlint/execute-rule": {
- "version": "7.5.0",
- "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-7.5.0.tgz",
- "integrity": "sha512-K66aoly8mxSHmBA/Y8bKSPPcCAR4GpJEsvHaLDYOG7GsyChu8NgCD53L8GUqPW8lBCWwnmCiSL+RlOkNHJ0Gag==",
- "dev": true,
- "requires": {
- "babel-runtime": "6.26.0"
- }
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-8.1.0.tgz",
+ "integrity": "sha512-+vpH3RFuO6ypuCqhP2rSqTjFTQ7ClzXtUvXphpROv9v9+7zH4L+Ex+wZLVkL8Xj2cxefSLn/5Kcqa9XyJTn3kg==",
+ "dev": true
},
"@commitlint/format": {
- "version": "7.5.0",
- "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-7.5.0.tgz",
- "integrity": "sha512-DEeQXfTLUm9kARliCBfw3SlQRAYjK2aXeRAUMs1HPhLA2tjNFFGv6LOpFFNdiu/WV+o1ojcgIvBBjpHaVT+Tvw==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-8.1.0.tgz",
+ "integrity": "sha512-D0cmabUTQIKdABgt08d9JAvO9+lMRAmkcsZx8TMScY502R67HCw77JhzRDcw1RmqX5rN8JO6ZjDHO92Pbwlt+Q==",
"dev": true,
"requires": {
- "babel-runtime": "^6.23.0",
"chalk": "^2.0.1"
}
},
"@commitlint/is-ignored": {
- "version": "7.5.1",
- "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-7.5.1.tgz",
- "integrity": "sha512-8JZCgy6bWSnjOT5cTTiyEAGp+Y4+5CUknhVbyiPxTRbjy6yF0aMKs1gMTfHrNHTKsasgmkCyPQd4C2eOPceuKA==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-8.1.0.tgz",
+ "integrity": "sha512-HUSxx6kuLbqrQ8jb5QRzo+yR+CIXgA9HNcIcZ1qWrb+O9GOixt3mlW8li1IcfIgfODlaWoxIz0jYCxR08IoQLg==",
"dev": true,
"requires": {
- "semver": "5.6.0"
+ "@types/semver": "^6.0.1",
+ "semver": "6.1.1"
+ },
+ "dependencies": {
+ "semver": {
+ "version": "6.1.1",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.1.1.tgz",
+ "integrity": "sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==",
+ "dev": true
+ }
}
},
"@commitlint/lint": {
- "version": "7.5.2",
- "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-7.5.2.tgz",
- "integrity": "sha512-DY/UfGFDquMno+5c6+tE50rMxpjdQK3CRG+nktgYlVz1UAqeUD+bRc3pvX5HwAsuGvyDrWAjtszHtEDeYJKcjw==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-8.1.0.tgz",
+ "integrity": "sha512-WYjbUgtqvnlVH3S3XPZMAa+N7KO0yQ+GuUG20Qra+EtER6SRYawykmEs4wAyrmY8VcFXUnKgSlIQUsqmGKwNZQ==",
"dev": true,
"requires": {
- "@commitlint/is-ignored": "^7.5.1",
- "@commitlint/parse": "^7.5.0",
- "@commitlint/rules": "^7.5.2",
+ "@commitlint/is-ignored": "^8.1.0",
+ "@commitlint/parse": "^8.1.0",
+ "@commitlint/rules": "^8.1.0",
"babel-runtime": "^6.23.0",
- "lodash": "4.17.11"
+ "lodash": "4.17.14"
+ },
+ "dependencies": {
+ "lodash": {
+ "version": "4.17.14",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz",
+ "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==",
+ "dev": true
+ }
}
},
"@commitlint/load": {
- "version": "7.5.0",
- "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-7.5.0.tgz",
- "integrity": "sha512-fhBER/rzPsteM6zq5qqMiOi+A2bHKCE/0PKmOzYgaqTKcG9c1SsOle9phPemW85to8Gxd2YgUOVLsZkCMltLtA==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-8.1.0.tgz",
+ "integrity": "sha512-ra02Dvmd7Gp1+uFLzTY3yGOpHjPzl5T9wYg/xrtPJNiOWXvQ0Mw7THw+ucd1M5iLUWjvdavv2N87YDRc428wHg==",
"dev": true,
"requires": {
- "@commitlint/execute-rule": "^7.5.0",
- "@commitlint/resolve-extends": "^7.5.0",
+ "@commitlint/execute-rule": "^8.1.0",
+ "@commitlint/resolve-extends": "^8.1.0",
"babel-runtime": "^6.23.0",
- "cosmiconfig": "^4.0.0",
- "lodash": "4.17.11",
- "resolve-from": "^4.0.0"
+ "chalk": "2.4.2",
+ "cosmiconfig": "^5.2.0",
+ "lodash": "4.17.14",
+ "resolve-from": "^5.0.0"
},
"dependencies": {
+ "lodash": {
+ "version": "4.17.14",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz",
+ "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==",
+ "dev": true
+ },
"resolve-from": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
- "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
+ "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
"dev": true
}
}
},
"@commitlint/message": {
- "version": "7.5.0",
- "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-7.5.0.tgz",
- "integrity": "sha512-5YOhsqy/MgHH7vyDsmmzO6Jr3ygr1pXbCm9NR3XB51wjg55Kd6/6dVlkhS/FmDp99pfwTdHb0TyeDFEjP98waw==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-8.1.0.tgz",
+ "integrity": "sha512-AjHq022G8jQQ/3YrBOjwVBD4xF75hvC3vcvFoBIb7cC8vad1QWq+1w+aks0KlEK5IW+/+7ORZXIH+oyW7h3+8A==",
"dev": true
},
"@commitlint/parse": {
- "version": "7.5.0",
- "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-7.5.0.tgz",
- "integrity": "sha512-hWASM8SBFTBtlFkKrEtD1qW6yTe2BsfoRiMKuYyRCTd+739TUF17og5vgQVuWttbGP0gXaciW44NygS2YjZmfA==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-8.1.0.tgz",
+ "integrity": "sha512-n4fEbZ5kdK5HChvne7Mj8rGGkKMfA4H11IuWiWmmMzgmZTNb/B04LPrzdUm4lm3f10XzM2JMM7PLXqofQJOGvA==",
"dev": true,
"requires": {
"conventional-changelog-angular": "^1.3.3",
@@ -1074,12 +1098,12 @@
}
},
"@commitlint/read": {
- "version": "7.5.0",
- "resolved": "https://registry.npmjs.org/@commitlint/read/-/read-7.5.0.tgz",
- "integrity": "sha512-uqGFCKZGnBUCTkxoCCJp4MfWUkegXkyT0T0RVM9diyG6uNWPWlMH1509sjLFlyeJKG+cSyYGG/d6T103ScMb4Q==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/read/-/read-8.1.0.tgz",
+ "integrity": "sha512-PKsGMQFEr2sX/+orI71b82iyi8xFqb7F4cTvsLxzB5x6/QutxPVM3rg+tEVdi6rBKIDuqRIp2puDZQuREZs3vg==",
"dev": true,
"requires": {
- "@commitlint/top-level": "^7.5.0",
+ "@commitlint/top-level": "^8.1.0",
"@marionebl/sander": "^0.6.0",
"babel-runtime": "^6.23.0",
"git-raw-commits": "^1.3.0"
@@ -1101,94 +1125,97 @@
}
},
"@commitlint/resolve-extends": {
- "version": "7.5.0",
- "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-7.5.0.tgz",
- "integrity": "sha512-FRIyPuqGvGa03OT4VgOHakizcw8YR5rdm77JsZff1rSnpxk6i+025I6qMeHqCIr5FaVIA0kR3FlC+MJFUs165A==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-8.1.0.tgz",
+ "integrity": "sha512-r/y+CeKW72Oa9BUctS1+I/MFCDiI3lfhwfQ65Tpfn6eZ4CuBYKzrCRi++GTHeAFKE3y8q1epJq5Rl/1GBejtBw==",
"dev": true,
"requires": {
- "babel-runtime": "6.26.0",
+ "@types/node": "^12.0.2",
"import-fresh": "^3.0.0",
- "lodash": "4.17.11",
- "resolve-from": "^4.0.0",
- "resolve-global": "^0.1.0"
+ "lodash": "4.17.14",
+ "resolve-from": "^5.0.0",
+ "resolve-global": "^1.0.0"
},
"dependencies": {
+ "@types/node": {
+ "version": "12.6.8",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-12.6.8.tgz",
+ "integrity": "sha512-aX+gFgA5GHcDi89KG5keey2zf0WfZk/HAQotEamsK2kbey+8yGKcson0hbK8E+v0NArlCJQCqMP161YhV6ZXLg==",
+ "dev": true
+ },
+ "lodash": {
+ "version": "4.17.14",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz",
+ "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==",
+ "dev": true
+ },
"resolve-from": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
- "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
+ "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
"dev": true
}
}
},
"@commitlint/rules": {
- "version": "7.5.2",
- "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-7.5.2.tgz",
- "integrity": "sha512-eDN1UFPcBOjdnlI3syuo7y99SjGH/dUV6S9NvBocAye8ln5dfKiI2shhWochJhl36r/kYWU8Wrvl2NZJL3c52g==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-8.1.0.tgz",
+ "integrity": "sha512-hlM8VfNjsOkbvMteFyqn0c3akiUjqG09Iid28MBLrXl/d+8BR3eTzwJ4wMta4oz/iqGyrIywvg1FpHrV977MPA==",
"dev": true,
"requires": {
- "@commitlint/ensure": "^7.5.2",
- "@commitlint/message": "^7.5.0",
- "@commitlint/to-lines": "^7.5.0",
+ "@commitlint/ensure": "^8.1.0",
+ "@commitlint/message": "^8.1.0",
+ "@commitlint/to-lines": "^8.1.0",
"babel-runtime": "^6.23.0"
}
},
"@commitlint/to-lines": {
- "version": "7.5.0",
- "resolved": "https://registry.npmjs.org/@commitlint/to-lines/-/to-lines-7.5.0.tgz",
- "integrity": "sha512-ZQ3LxPNuQ/J7q42hkiPWN5fUIjWae85H2HHoBB+/Rw1fo+oehvr4Xyt+Oa9Mx5WbBnev/wXnUFjXgoadv1RZ5A==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/to-lines/-/to-lines-8.1.0.tgz",
+ "integrity": "sha512-Lh4OH1bInI8GME/7FggS0/XkIMEJdTObMbXRyPRGaPcWH5S7zpB6y+b4qjzBHXAbEv2O46QAAMjZ+ywPQCpmYQ==",
"dev": true
},
"@commitlint/top-level": {
- "version": "7.5.0",
- "resolved": "https://registry.npmjs.org/@commitlint/top-level/-/top-level-7.5.0.tgz",
- "integrity": "sha512-oTu185GufTYHjTXPHu6k6HL7iuASOvDOtQizZWRSxj0VXuoki6e0HzvGZsRsycDTOn04Q9hVu+PhF83IUwRpeg==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/top-level/-/top-level-8.1.0.tgz",
+ "integrity": "sha512-EvQuofuA/+0l1w9pkG/PRyIwACmZdIh9qxyax7w7mR8qqmSHscqf2jARIylh1TOx0uI9egO8MuPLiwC1RwyREA==",
"dev": true,
"requires": {
- "find-up": "^2.1.0"
+ "find-up": "^4.0.0"
},
"dependencies": {
"find-up": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
- "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=",
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
+ "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"dev": true,
"requires": {
- "locate-path": "^2.0.0"
+ "locate-path": "^5.0.0",
+ "path-exists": "^4.0.0"
}
},
"locate-path": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz",
- "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=",
- "dev": true,
- "requires": {
- "p-locate": "^2.0.0",
- "path-exists": "^3.0.0"
- }
- },
- "p-limit": {
- "version": "1.3.0",
- "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
- "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==",
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
+ "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"dev": true,
"requires": {
- "p-try": "^1.0.0"
+ "p-locate": "^4.1.0"
}
},
"p-locate": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz",
- "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
+ "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"dev": true,
"requires": {
- "p-limit": "^1.1.0"
+ "p-limit": "^2.2.0"
}
},
- "p-try": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
- "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=",
+ "path-exists": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
+ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"dev": true
}
}
@@ -1438,6 +1465,12 @@
"integrity": "sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ==",
"dev": true
},
+ "@types/semver": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/@types/semver/-/semver-6.0.1.tgz",
+ "integrity": "sha512-ffCdcrEE5h8DqVxinQjo+2d1q+FV5z7iNtPofw3JsrltSoSVlOGaW0rY8XxtO9XukdTn8TaCGWmk2VFGhI70mg==",
+ "dev": true
+ },
"@types/stack-utils": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz",
@@ -2088,14 +2121,6 @@
"requires": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
- },
- "dependencies": {
- "regenerator-runtime": {
- "version": "0.11.1",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
- "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==",
- "dev": true
- }
}
},
"balanced-match": {
@@ -3139,9 +3164,9 @@
"dev": true
},
"core-js": {
- "version": "2.6.5",
- "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.5.tgz",
- "integrity": "sha512-klh/kDpwX8hryYL14M9w/xei6vrv6sE8gTHDG7/T/+SEovB/G4ejwcfE/CBzO6Edsu+OETZMZ3wcX/EjUkrl5A==",
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz",
+ "integrity": "sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==",
"dev": true
},
"core-js-compat": {
@@ -3177,15 +3202,27 @@
"dev": true
},
"cosmiconfig": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-4.0.0.tgz",
- "integrity": "sha512-6e5vDdrXZD+t5v0L8CrurPeybg4Fmf+FCSYxXKYVAqLUtyCSbuyqE059d0kDthTNRzKVjL7QMgNpEUlsoYH3iQ==",
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz",
+ "integrity": "sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA==",
"dev": true,
"requires": {
+ "import-fresh": "^2.0.0",
"is-directory": "^0.3.1",
- "js-yaml": "^3.9.0",
- "parse-json": "^4.0.0",
- "require-from-string": "^2.0.1"
+ "js-yaml": "^3.13.1",
+ "parse-json": "^4.0.0"
+ },
+ "dependencies": {
+ "import-fresh": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-2.0.0.tgz",
+ "integrity": "sha1-2BNVwVYS04bGH53dOSLUMEgipUY=",
+ "dev": true,
+ "requires": {
+ "caller-path": "^2.0.0",
+ "resolve-from": "^3.0.0"
+ }
+ }
}
},
"create-ecdh": {
@@ -5831,9 +5868,9 @@
"dev": true
},
"handlebars": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.1.tgz",
- "integrity": "sha512-3Zhi6C0euYZL5sM0Zcy7lInLXKQ+YLcF/olbN010mzGQ4XVm50JeyBnMqofHh696GrciGruC7kCcApPDJvVgwA==",
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz",
+ "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==",
"dev": true,
"requires": {
"neo-async": "^2.6.0",
@@ -7135,9 +7172,9 @@
"dev": true
},
"js-yaml": {
- "version": "3.13.0",
- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.0.tgz",
- "integrity": "sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ==",
+ "version": "3.13.1",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
+ "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
@@ -7600,9 +7637,9 @@
}
},
"lodash": {
- "version": "4.17.11",
- "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
- "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==",
+ "version": "4.17.15",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
+ "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
"dev": true
},
"lodash._reinterpolate": {
@@ -8022,9 +8059,9 @@
}
},
"mixin-deep": {
- "version": "1.3.1",
- "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz",
- "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==",
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz",
+ "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==",
"dev": true,
"requires": {
"for-in": "^1.0.2",
@@ -9214,9 +9251,9 @@
}
},
"regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA==",
+ "version": "0.11.1",
+ "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
+ "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==",
"dev": true
},
"regenerator-transform": {
@@ -9435,12 +9472,6 @@
"integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=",
"dev": true
},
- "require-from-string": {
- "version": "2.0.2",
- "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
- "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
- "dev": true
- },
"require-main-filename": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz",
@@ -9472,12 +9503,12 @@
"dev": true
},
"resolve-global": {
- "version": "0.1.0",
- "resolved": "https://registry.npmjs.org/resolve-global/-/resolve-global-0.1.0.tgz",
- "integrity": "sha1-j7As/Vt9sgEY6IYxHxWvlb0V+9k=",
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/resolve-global/-/resolve-global-1.0.0.tgz",
+ "integrity": "sha512-zFa12V4OLtT5XUX/Q4VLvTfBf+Ok0SPc1FNGM/z9ctUdiU618qwKpWnd0CHs3+RqROfyEg/DhuHbMWYqcgljEw==",
"dev": true,
"requires": {
- "global-dirs": "^0.1.0"
+ "global-dirs": "^0.1.1"
}
},
"resolve-url": {
@@ -9657,9 +9688,9 @@
"dev": true
},
"set-value": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz",
- "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==",
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz",
+ "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==",
"dev": true,
"requires": {
"extend-shallow": "^2.0.1",
@@ -10633,14 +10664,23 @@
"dev": true
},
"uglify-js": {
- "version": "3.5.2",
- "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.2.tgz",
- "integrity": "sha512-imog1WIsi9Yb56yRt5TfYVxGmnWs3WSGU73ieSOlMVFwhJCA9W8fqFFMMj4kgDqiS/80LGdsYnWL7O9UcjEBlg==",
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz",
+ "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==",
"dev": true,
"optional": true,
"requires": {
- "commander": "~2.19.0",
+ "commander": "~2.20.0",
"source-map": "~0.6.1"
+ },
+ "dependencies": {
+ "commander": {
+ "version": "2.20.0",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz",
+ "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==",
+ "dev": true,
+ "optional": true
+ }
}
},
"unicode-canonical-property-names-ecmascript": {
@@ -10672,29 +10712,15 @@
"dev": true
},
"union-value": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz",
- "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=",
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
+ "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==",
"dev": true,
"requires": {
"arr-union": "^3.1.0",
"get-value": "^2.0.6",
"is-extendable": "^0.1.1",
- "set-value": "^0.4.3"
- },
- "dependencies": {
- "set-value": {
- "version": "0.4.3",
- "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz",
- "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=",
- "dev": true,
- "requires": {
- "extend-shallow": "^2.0.1",
- "is-extendable": "^0.1.1",
- "is-plain-object": "^2.0.1",
- "to-object-path": "^0.3.0"
- }
- }
+ "set-value": "^2.0.1"
}
},
"uniq": {
diff --git a/package.json b/package.json
index eae0fb0f..3f01d9ee 100644
--- a/package.json
+++ b/package.json
@@ -50,7 +50,7 @@
"@babel/cli": "^7.2.3",
"@babel/core": "^7.4.0",
"@babel/preset-env": "^7.4.2",
- "@commitlint/cli": "^7.5.2",
+ "@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^7.5.0",
"@webpack-contrib/defaults": "^3.0.0",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
diff --git a/src/addStyles.js b/src/addStyles.js
index 4527af90..53542a9f 100644
--- a/src/addStyles.js
+++ b/src/addStyles.js
@@ -71,8 +71,6 @@ var singleton = null;
var singletonCounter = 0;
var stylesInsertedAtTop = [];
-var fixUrls = require('./urls');
-
module.exports = function(list, options) {
if (typeof DEBUG !== 'undefined' && DEBUG) {
if (typeof document !== 'object') {
@@ -256,21 +254,6 @@ function createStyleElement(options) {
return style;
}
-function createLinkElement(options) {
- var link = document.createElement('link');
-
- if (options.attrs.type === undefined) {
- options.attrs.type = 'text/css';
- }
-
- options.attrs.rel = 'stylesheet';
-
- addAttrs(link, options.attrs);
- insertStyleElement(options, link);
-
- return link;
-}
-
function addAttrs(el, attrs) {
Object.keys(attrs).forEach(function(key) {
el.setAttribute(key, attrs[key]);
@@ -315,23 +298,6 @@ function addStyle(obj, options) {
update = applyToSingletonTag.bind(null, style, styleIndex, false);
remove = applyToSingletonTag.bind(null, style, styleIndex, true);
- } else if (
- obj.sourceMap &&
- typeof URL === 'function' &&
- typeof URL.createObjectURL === 'function' &&
- typeof URL.revokeObjectURL === 'function' &&
- typeof Blob === 'function' &&
- typeof btoa === 'function'
- ) {
- style = createLinkElement(options);
- update = updateLink.bind(null, style, options);
- remove = function() {
- removeStyleElement(style);
-
- if (style.href) {
- URL.revokeObjectURL(style.href);
- }
- };
} else {
style = createStyleElement(options);
update = applyToTag.bind(null, style);
@@ -393,11 +359,20 @@ function applyToSingletonTag(style, index, remove, obj) {
function applyToTag(style, obj) {
var css = obj.css;
var media = obj.media;
+ var sourceMap = obj.sourceMap;
if (media) {
style.setAttribute('media', media);
}
+ if (sourceMap) {
+ css +=
+ '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
+ // http://stackoverflow.com/a/26603875
+ '\n/*# sourceMappingURL=data:application/json;base64,' +
+ btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
+ }
+
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
@@ -408,38 +383,3 @@ function applyToTag(style, obj) {
style.appendChild(document.createTextNode(css));
}
}
-
-function updateLink(link, options, obj) {
- var css = obj.css;
- var sourceMap = obj.sourceMap;
-
- /*
- If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
- and there is no publicPath defined then lets turn convertToAbsoluteUrls
- on by default. Otherwise default to the convertToAbsoluteUrls option
- directly
- */
- var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
-
- if (options.convertToAbsoluteUrls || autoFixUrls) {
- css = fixUrls(css);
- }
-
- if (sourceMap) {
- // http://stackoverflow.com/a/26603875
- css +=
- '\n/*# sourceMappingURL=data:application/json;base64,' +
- btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) +
- ' */';
- }
-
- var blob = new Blob([css], { type: 'text/css' });
-
- var oldSrc = link.href;
-
- link.href = URL.createObjectURL(blob);
-
- if (oldSrc) {
- URL.revokeObjectURL(oldSrc);
- }
-}
diff --git a/src/options.json b/src/options.json
index 9be524c8..d30cee5a 100644
--- a/src/options.json
+++ b/src/options.json
@@ -24,9 +24,6 @@
},
"sourceMap": {
"type": "boolean"
- },
- "convertToAbsoluteUrls": {
- "type": "boolean"
}
},
"additionalProperties": false
diff --git a/src/urls.js b/src/urls.js
deleted file mode 100644
index c610ee5d..00000000
--- a/src/urls.js
+++ /dev/null
@@ -1,98 +0,0 @@
-/* eslint-disable */
-
-/**
- * When source maps are enabled, `style-loader` uses a link element with a data-uri to
- * embed the css on the page. This breaks all relative urls because now they are relative to a
- * bundle instead of the current page.
- *
- * One solution is to only use full urls, but that may be impossible.
- *
- * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
- *
- * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
- *
- */
-
-module.exports = function(css) {
- // get current location
- var location = typeof window !== 'undefined' && window.location;
-
- if (!location) {
- throw new Error('fixUrls requires window.location');
- }
-
- // blank or null?
- if (!css || typeof css !== 'string') {
- return css;
- }
-
- var baseUrl = location.protocol + '//' + location.host;
- var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, '/');
-
- // convert each url(...)
- /*
- This regular expression is just a way to recursively match brackets within
- a string.
- /url\s*\( = Match on the word "url" with any whitespace after it and then a parens
- ( = Start a capturing group
- (?: = Start a non-capturing group
- [^)(] = Match anything that isn't a parentheses
- | = OR
- \( = Match a start parentheses
- (?: = Start another non-capturing groups
- [^)(]+ = Match anything that isn't a parentheses
- | = OR
- \( = Match a start parentheses
- [^)(]* = Match anything that isn't a parentheses
- \) = Match a end parentheses
- ) = End Group
- *\) = Match anything and then a close parens
- ) = Close non-capturing group
- * = Match anything
- ) = Close capturing group
- \) = Match a close parens
- /gi = Get all matches, not the first. Be case insensitive.
- */
- return css.replace(
- /url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,
- function(fullMatch, origUrl) {
- // strip quotes (if they exist)
- var unquotedOrigUrl = origUrl
- .trim()
- .replace(/^"(.*)"$/, function(o, $1) {
- return $1;
- })
- .replace(/^'(.*)'$/, function(o, $1) {
- return $1;
- });
-
- // already a full url? no change
- if (
- /^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(
- unquotedOrigUrl
- )
- ) {
- return fullMatch;
- }
-
- // convert the url to a full url
- var newUrl;
-
- if (unquotedOrigUrl.indexOf('//') === 0) {
- // TODO: should we add protocol?
- newUrl = unquotedOrigUrl;
- } else if (unquotedOrigUrl.indexOf('/') === 0) {
- // Path should be relative to the base url
- // already starts with '/'
- newUrl = baseUrl + unquotedOrigUrl;
- } else {
- // Path should be relative to current directory
- // Strip leading './'
- newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, '');
- }
-
- // send back the fixed url(...)
- return 'url(' + JSON.stringify(newUrl) + ')';
- }
- );
-};
diff --git a/test/fixUrls.test.js b/test/fixUrls.test.js
deleted file mode 100644
index b07d94db..00000000
--- a/test/fixUrls.test.js
+++ /dev/null
@@ -1,234 +0,0 @@
-const url = require('url');
-
-const semver = require('semver');
-
-const fixUrls = require('../src/urls');
-
-describe('fix urls tests', () => {
- const defaultUrl = 'https://x.y.z/a/b.html';
-
- const assertUrl = (origCss, expectedCss, specialUrl) => {
- // jsdom doesn't work with location on node@6 and anode@8
- if (semver.lte(process.version, '10.0.0')) {
- expect(true).toBe(true);
-
- return;
- }
-
- Object.defineProperty(window, 'location', {
- writable: true,
- value: specialUrl ? url.parse(specialUrl) : url.parse(defaultUrl),
- });
-
- const resultCss = fixUrls(origCss);
-
- expect(expectedCss || origCss).toBe(resultCss);
- };
-
- // no change
- it('Null css is not modified', () => {
- assertUrl(null);
- });
-
- it('Blank css is not modified', () => {
- assertUrl('');
- });
-
- it('No url is not modified', () => {
- assertUrl('body { }');
- });
-
- it("Full url isn't changed (no quotes)", () => {
- assertUrl('body { background-image:url(http://example.com/bg.jpg); }');
- });
-
- it("Full url isn't changed (no quotes, spaces)", () => {
- assertUrl('body { background-image:url ( http://example.com/bg.jpg ); }');
- });
-
- it("Full url isn't changed (double quotes)", () => {
- assertUrl('body { background-image:url("http://example.com/bg.jpg"); }');
- });
-
- it("Full url isn't changed (double quotes, spaces)", () => {
- assertUrl(
- 'body { background-image:url ( "http://example.com/bg.jpg" ); }'
- );
- });
-
- it("Full url isn't changed (single quotes)", () => {
- assertUrl("body { background-image:url('http://example.com/bg.jpg'); }");
- });
-
- it("Full url isn't changed (single quotes, spaces)", () => {
- assertUrl(
- "body { background-image:url ( 'http://example.com/bg.jpg' ); }"
- );
- });
-
- it('Multiple full urls are not changed', () => {
- assertUrl(
- "body { background-image:url(http://example.com/bg.jpg); }\ndiv.main { background-image:url ( 'https://www.anothersite.com/another.png' ); }"
- );
- });
-
- it("Http url isn't changed", () => {
- assertUrl('body { background-image:url(http://example.com/bg.jpg); }');
- });
-
- it("Https url isn't changed", () => {
- assertUrl('body { background-image:url(https://example.com/bg.jpg); }');
- });
-
- it("HTTPS url isn't changed", () => {
- assertUrl('body { background-image:url(HTTPS://example.com/bg.jpg); }');
- });
-
- it("File url isn't changed", () => {
- assertUrl('body { background-image:url(file:///example.com/bg.jpg); }');
- });
-
- it("Double slash url isn't changed", () => {
- assertUrl(
- 'body { background-image:url(//example.com/bg.jpg); }',
- 'body { background-image:url("//example.com/bg.jpg"); }'
- );
- });
-
- it("Image data uri url isn't changed", () => {
- assertUrl(
- 'body { background-image:url(data:image/png;base64,qsrwABYuwNkimqm3gAAAABJRU5ErkJggg==); }'
- );
- });
-
- it("Font data uri url isn't changed", () => {
- assertUrl(
- 'body { background-image:url(data:application/x-font-woff;charset=utf-8;base64,qsrwABYuwNkimqm3gAAAABJRU5ErkJggg); }'
- );
- });
-
- // relative urls
- it('Relative url', () => {
- assertUrl(
- 'body { background-image:url (bg.jpg); }',
- 'body { background-image:url("https://x.y.z/a/bg.jpg"); }',
- 'https://x.y.z/a/'
- );
- });
-
- it('Relative url case sensitivity', () => {
- assertUrl(
- 'body { background-image:URL (bg.jpg); }',
- 'body { background-image:url("https://x.y.z/a/bg.jpg"); }',
- 'https://x.y.z/a/'
- );
- });
-
- it('Relative url with path', () => {
- assertUrl(
- 'body { background-image:url(c/d/bg.jpg); }',
- 'body { background-image:url("https://x.y.z/a/c/d/bg.jpg"); }',
- 'https://x.y.z/a/'
- );
- });
-
- it('Relative url with dot slash', () => {
- assertUrl(
- 'body { background-image:url(./c/d/bg.jpg); }',
- 'body { background-image:url("https://x.y.z/a/c/d/bg.jpg"); }',
- 'https://x.y.z/a/'
- );
- });
-
- it('Multiple relative urls', () => {
- assertUrl(
- 'body { background-image:url(bg.jpg); }\ndiv.main { background-image:url(./c/d/bg.jpg); }',
- 'body { background-image:url("https://x.y.z/a/bg.jpg"); }\ndiv.main { background-image:url("https://x.y.z/a/c/d/bg.jpg"); }',
- 'https://x.y.z/a/'
- );
- });
-
- it('Relative url that looks like data-uri', () => {
- assertUrl(
- 'body { background-image:url(data/image/png.base64); }',
- 'body { background-image:url("https://x.y.z/a/data/image/png.base64"); }',
- 'https://x.y.z/a/'
- );
- });
-
- // urls with hashes
- it('Relative url with hash are not changed', () => {
- assertUrl('body { background-image:url(#bg.jpg); }');
- });
-
- // empty urls
- it('Empty url should be skipped', () => {
- assertUrl('body { background-image:url(); }');
- assertUrl('body { background-image:url( ); }');
- assertUrl('body { background-image:url(\n); }');
- assertUrl("body { background-image:url(''); }");
- assertUrl("body { background-image:url(' '); }");
- assertUrl('body { background-image:url(""); }');
- assertUrl('body { background-image:url(" "); }');
- });
-
- // rooted urls
- it('Rooted url', () => {
- assertUrl(
- 'body { background-image:url(/bg.jpg); }',
- 'body { background-image:url("https://x.y.z/bg.jpg"); }',
- 'https://x.y.z'
- );
- });
- it('Rooted url with path', () => {
- assertUrl(
- 'body { background-image:url(/a/b/bg.jpg); }',
- 'body { background-image:url("https://x.y.z/a/b/bg.jpg"); }',
- 'https://x.y.z'
- );
- });
-
- // special locations
- it('Location with no path, filename only', () => {
- assertUrl(
- 'body { background-image:url(bg.jpg); }',
- 'body { background-image:url("http://x.y.z/bg.jpg"); }',
- 'http://x.y.z'
- );
- });
-
- it('Location with no path, path with filename', () => {
- assertUrl(
- 'body { background-image:url(a/bg.jpg); }',
- 'body { background-image:url("http://x.y.z/a/bg.jpg"); }',
- 'http://x.y.z'
- );
- });
- it('Location with no path, rel path with filename', () => {
- assertUrl(
- 'body { background-image:url(./a/bg.jpg); }',
- 'body { background-image:url("http://x.y.z/a/bg.jpg"); }',
- 'http://x.y.z'
- );
- });
- it('Location with no path, root filename', () => {
- assertUrl(
- 'body { background-image:url(/a/bg.jpg); }',
- 'body { background-image:url("http://x.y.z/a/bg.jpg"); }',
- 'http://x.y.z'
- );
- });
-
- it("Doesn't break inline SVG", () => {
- const svg =
- 'url(\'data:image/svg+xml;charset=utf-8, \')';
-
- assertUrl(`body: { background: ${svg} }`);
- });
- it("Doesn't break inline SVG with HTML comment", () => {
- const svg =
- "url('data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%0A%3C!--%20Comment%20--%3E%0A%3Csvg%3E%3C%2Fsvg%3E%0A')";
-
- assertUrl(`body: { background: ${svg} }`);
- });
-});