New upstream version 0.23.1

parent fe885ecf
unit_tests: &unit_tests
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: NPM Rebuild
command: npm install
- run:
name: Run unit tests.
command: npm run ci:test
canary_tests: &canary_tests
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: NPM Rebuild
command: npm install
- run:
name: Install Webpack Canary
command: npm i --no-save webpack@next
- run:
name: Run unit tests.
command: if [[ $(compver --name webpack --gte next --lt latest) < 1 ]] ; then printf "n00p Canary Suite"; else npm run ci:test ; fi
version: 2
jobs:
dependency_cache:
docker:
- image: webpackcontrib/circleci-node-base:latest
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: Install Dependencies
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
node8-latest:
docker:
- image: webpackcontrib/circleci-node8:latest
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: NPM Rebuild
command: npm install
- run:
name: Run unit tests.
command: npm run ci:coverage
- run:
name: Submit coverage data to codecov.
command: bash <(curl -s https://codecov.io/bash)
when: on_success
node6-latest:
docker:
- image: webpackcontrib/circleci-node6:latest
<<: *unit_tests
node9-latest:
docker:
- image: webpackcontrib/circleci-node9:latest
<<: *unit_tests
node8-canary:
docker:
- image: webpackcontrib/circleci-node8:latest
<<: *canary_tests
analysis:
docker:
- image: webpackcontrib/circleci-node-base:latest
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: NPM Rebuild
command: npm install
# - run:
# name: Run linting.
# command: npm run lint
- run:
name: Run NSP Security Check.
command: npm run security
# - run:
# name: Validate Commit Messages
# command: npm run ci:lint:commits
publish:
docker:
- image: webpackcontrib/circleci-node-base:latest
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: NPM Rebuild
command: npm install
# - run:
# name: Validate Commit Messages
# command: npm run release:validate
- run:
name: Publish to NPM
command: printf "noop running conventional-github-releaser"
version: 2.0
workflows:
version: 2
validate-publish:
jobs:
- dependency_cache
- node6-latest:
requires:
- dependency_cache
filters:
tags:
only: /.*/
- analysis:
requires:
- dependency_cache
filters:
tags:
only: /.*/
- node8-latest:
requires:
- analysis
- node6-latest
filters:
tags:
only: /.*/
- node9-latest:
requires:
- analysis
- node6-latest
filters:
tags:
only: /.*/
- node8-canary:
requires:
- analysis
- node6-latest
filters:
tags:
only: /.*/
- publish:
requires:
- node8-latest
- node8-canary
- node9-latest
filters:
branches:
only:
- master
\ No newline at end of file
/node_modules
.idea/
/coverage
\ No newline at end of file
sudo: false
language: node_js
branches:
only:
- master
matrix:
fast_finish: true
include:
# - os: linux
# node_js: '7'
# env: WEBPACK_VERSION="2.2.0" BITHOUND_CHECK=true JOB_PART=lint
- os: linux
node_js: '7'
env: WEBPACK_VERSION="2.2.0" JOB_PART=test
- os: linux
node_js: '4.3'
env: WEBPACK_VERSION="2.2.0" JOB_PART=test
- os: linux
node_js: '6'
env: WEBPACK_VERSION="2.2.0" JOB_PART=test
# - os: linux
# node_js: '7'
# env: WEBPACK_VERSION="2.2.0" JOB_PART=coverage
before_install:
- nvm --version
- node --version
before_script:
- if [ "$WEBPACK_VERSION" ]; then yarn add webpack@^$WEBPACK_VERSION; fi
# - if [ "$BITHOUND_CHECK" ]; then npm install -g bithound; bithound check git@github.com:$TRAVIS_REPO_SLUG.git; fi
script:
- yarn run travis:$JOB_PART
after_success:
- bash <(curl -s https://codecov.io/bash)
\ No newline at end of file
......@@ -2,6 +2,167 @@
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.
<a name="0.23.1"></a>
## [0.23.1](https://github.com/webpack-contrib/style-loader/compare/v0.23.0...v0.23.1) (2018-10-08)
### Bug Fixes
* **addStyles:** support exports of transpiled transforms (`options.transform`) ([#333](https://github.com/webpack-contrib/style-loader/issues/333)) ([33aebed](https://github.com/webpack-contrib/style-loader/commit/33aebed))
<a name="0.23.0"></a>
# [0.23.0](https://github.com/webpack-contrib/style-loader/compare/v0.22.1...v0.23.0) (2018-08-27)
### Features
* **useable:** add `insertInto` support (`options.insertInto`) ([#341](https://github.com/webpack-contrib/style-loader/issues/341)) ([2588aca](https://github.com/webpack-contrib/style-loader/commit/2588aca))
<a name="0.22.1"></a>
## [0.22.1](https://github.com/webpack-contrib/style-loader/compare/v0.22.0...v0.22.1) (2018-08-08)
### Bug Fixes
* **addStyles:** use `var` instead of `const` (IE fix) ([#338](https://github.com/webpack-contrib/style-loader/issues/338)) ([1ca12ab](https://github.com/webpack-contrib/style-loader/commit/1ca12ab))
<a name="0.22.0"></a>
# [0.22.0](https://github.com/webpack-contrib/style-loader/compare/v0.21.0...v0.22.0) (2018-08-07)
### Bug Fixes
* insertInto and insertAt collaboration ([#325](https://github.com/webpack-contrib/style-loader/issues/325)) ([c7d8fec](https://github.com/webpack-contrib/style-loader/commit/c7d8fec))
### Features
* add support for __webpack_nonce__ ([#319](https://github.com/webpack-contrib/style-loader/issues/319)) ([fc24512](https://github.com/webpack-contrib/style-loader/commit/fc24512))
<a name="0.21.0"></a>
# [0.21.0](https://github.com/webpack-contrib/style-loader/compare/v0.20.3...v0.21.0) (2018-04-18)
### Features
* enable tag type configuration ([#316](https://github.com/webpack-contrib/style-loader/issues/316)) ([892cba5](https://github.com/webpack-contrib/style-loader/commit/892cba5))
<a name="0.20.3"></a>
## [0.20.3](https://github.com/webpack-contrib/style-loader/compare/v0.20.2...v0.20.3) (2018-03-09)
### Bug Fixes
* **package:** update `schema-utils` v0.4.3...0.4.5 (`dependencies`) ([#308](https://github.com/webpack-contrib/style-loader/issues/308)) ([9455888](https://github.com/webpack-contrib/style-loader/commit/9455888))
<a name="0.20.2"></a>
## [0.20.2](https://github.com/webpack-contrib/style-loader/compare/v0.20.1...v0.20.2) (2018-02-15)
### Bug Fixes
* **urls:** skip empty `url()` handling ([#304](https://github.com/webpack-contrib/style-loader/issues/304)) ([64f12dc](https://github.com/webpack-contrib/style-loader/commit/64f12dc))
<a name="0.20.1"></a>
## [0.20.1](https://github.com/webpack-contrib/style-loader/compare/v0.20.0...v0.20.1) (2018-01-26)
### Bug Fixes
* **index:** source code indentation ([#299](https://github.com/webpack-contrib/style-loader/issues/299)) ([b4642e7](https://github.com/webpack-contrib/style-loader/commit/b4642e7))
<a name="0.20.0"></a>
# [0.20.0](https://github.com/webpack-contrib/style-loader/compare/v0.19.1...v0.20.0) (2018-01-26)
### Bug Fixes
* **addStyles:** check if `HTMLIFrameElement` exist ([#296](https://github.com/webpack-contrib/style-loader/issues/296)) ([9b46128](https://github.com/webpack-contrib/style-loader/commit/9b46128))
* **index:** enable HMR in case `locals` (`css-modules`) are unchanged ([#298](https://github.com/webpack-contrib/style-loader/issues/298)) ([3a4cb53](https://github.com/webpack-contrib/style-loader/commit/3a4cb53))
* **options:** add `transform` option validation (`{String}`) ([23c3567](https://github.com/webpack-contrib/style-loader/commit/23c3567))
* **options:** support passing a `{Function}` (`options.insertInto`) ([e0c4b19](https://github.com/webpack-contrib/style-loader/commit/e0c4b19))
### Features
* support passing a `{Function}` (`options.insertInto`) ([#279](https://github.com/webpack-contrib/style-loader/issues/279)) ([0eb8fe7](https://github.com/webpack-contrib/style-loader/commit/0eb8fe7))
<a name="0.19.1"></a>
## [0.19.1](https://github.com/webpack/style-loader/compare/v0.19.0...v0.19.1) (2017-12-14)
### Bug Fixes
* **addStyles:** correctly check `singleton` behavior when `{Boolean}` (`options.singleton`) ([#285](https://github.com/webpack/style-loader/issues/285)) ([2bfc93e](https://github.com/webpack/style-loader/commit/2bfc93e))
<a name="0.19.0"></a>
# [0.19.0](https://github.com/webpack/style-loader/compare/v0.18.2...v0.19.0) (2017-10-03)
### Features
* add option to enable/disable HMR (`options.hmr`) ([#264](https://github.com/webpack/style-loader/issues/264)) ([378e906](https://github.com/webpack/style-loader/commit/378e906))
* add support for iframes (`options.insertInto`) ([#248](https://github.com/webpack/style-loader/issues/248)) ([25e8e89](https://github.com/webpack/style-loader/commit/25e8e89))
* support 'before' insertions (`options.insertAt`) ([#253](https://github.com/webpack/style-loader/issues/253)) ([67120f8](https://github.com/webpack/style-loader/commit/67120f8))
<a name="0.18.2"></a>
## [0.18.2](https://github.com/webpack/style-loader/compare/v0.18.1...v0.18.2) (2017-06-05)
### Bug Fixes
* **url:** use `loaderUtils.stringifyRequest` to avoid invalidating hashes due to absolute paths ([#242](https://github.com/webpack/style-loader/issues/242)) ([97508ec](https://github.com/webpack/style-loader/commit/97508ec))
* Add `null` check to `removeStyleElement` ([#245](https://github.com/webpack/style-loader/issues/245)) ([0a4845c](https://github.com/webpack/style-loader/commit/0a4845c))
<a name="0.18.1"></a>
## [0.18.1](https://github.com/webpack/style-loader/compare/v0.18.0...v0.18.1) (2017-05-23)
### Bug Fixes
* **addStyles:** revert merged loops ([#236](https://github.com/webpack/style-loader/issues/236)) ([fbd04b1](https://github.com/webpack/style-loader/commit/fbd04b1))
<a name="0.18.0"></a>
# [0.18.0](https://github.com/webpack/style-loader/compare/v0.17.0...v0.18.0) (2017-05-22)
### Bug Fixes
* stringify the options.transform request ([#230](https://github.com/webpack/style-loader/issues/230)) ([5888095](https://github.com/webpack/style-loader/commit/5888095))
### Features
* add options validation ([#224](https://github.com/webpack/style-loader/issues/224)) ([4b6b70d](https://github.com/webpack/style-loader/commit/4b6b70d))
<a name="0.17.0"></a>
# [0.17.0](https://github.com/webpack/style-loader/compare/v0.16.1...v0.17.0) (2017-05-01)
......
......@@ -9,16 +9,16 @@
src="https://webpack.js.org/assets/icon-square-big.svg">
</a>
<h1>Style Loader</h1>
<p>Adds CSS to the DOM by injecting a `<style>` tag</p>
<p>Adds CSS to the DOM by injecting a <code>&lt;style&gt;</code> tag</p>
</div>
<h2 align="center">Install</h2>
```
```bash
npm install style-loader --save-dev
```
<h2 align="center"><a href="https://webpack.js.org/concepts/loaders">Usage</a></h2>
<h2 align="center">Usage</h2>
It's recommended to combine `style-loader` with the [`css-loader`](https://github.com/webpack/css-loader)
......@@ -57,7 +57,7 @@ style.className === "z849f98ca812"
### `Url`
It's also possible to add a URL `<link href="path/to/file.css" rel="stylesheet">` instead of a inlining the CSS `{String}` with `<style></style>` tag.
It's also possible to add a URL `<link href="path/to/file.css" rel="stylesheet">` instead of inlining the CSS `{String}` with `<style></style>` tag.
```js
import url from 'file.css'
......@@ -84,10 +84,12 @@ import url from 'file.css'
<link rel="stylesheet" href="path/to/file.css">
```
> :information_source: 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.
> ℹ️ 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()`
By convention the `Reference Counter API` should be bound to `.useable.css` and the `.css` should be loaded with basic `style-loader` usage.(similar to other file types, i.e. `.useable.less` and `.less`).
**webpack.config.js**
......@@ -128,19 +130,36 @@ style.unuse(); // = style.unref();
Styles are not added on `import/require()`, but instead on call to `use`/`ref`. Styles are removed from page if `unuse`/`unref` is called exactly as often as `use`/`ref`.
:warning: Behavior is undefined when `unuse`/`unref` is called more often than `use`/`ref`. Don't do that.
> ⚠️ Behavior is undefined when `unuse`/`unref` is called more often than `use`/`ref`. Don't do that.
<h2 align="center">Options</h2>
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|**`hmr`**|`{Boolean}`|`true`|Enable/disable Hot Module Replacement (HMR), if disabled no HMR Code will be added (good for non local development/production)|
|**`base`** |`{Number}`|`true`|Set module ID base (DLLPlugin)|
|**`attrs`**|`{Object}`|`{}`|Add custom attrs to `<style></style>`|
|**`transform`** |`{Function}`|`false`|Transform/Conditionally load CSS by passing a transform/condition function|
|**`insertAt`**|`{String}`|`bottom`|Inserts `<style></style>` at the given position|
|**`insertInto`**|`{String}`|`<head>`|Inserts `<style></style>` into the given position|
|**`insertAt`**|`{String\|Object}`|`bottom`|Inserts `<style></style>` at the given position|
|**`insertInto`**|`{String\|Function}`|`<head>`|Inserts `<style></style>` into the given position|
|**`singleton`**|`{Boolean}`|`undefined`|Reuses a single `<style></style>` element, instead of adding/removing individual elements for each required module.|
|**`sourceMap`**|`{Boolean}`|`false`|Enable/Disable Sourcemaps|
|**`convertToAbsoluteUrls`**|`{Boolean}`|`false`|Coverts relative URLs to absolute urls, when source maps are enabled|
|**`convertToAbsoluteUrls`**|`{Boolean}`|`false`|Converts relative URLs to absolute urls, when source maps are enabled|
### `hmr`
Enable/disable Hot Module Replacement (HMR), if disabled no HMR Code will be added.
This could be used for non local development and production.
**webpack.config.js**
```js
{
loader: 'style-loader',
options: {
hmr: false
}
}
```
### `base`
......@@ -193,7 +212,7 @@ import style from './file.css'
{
test: /\.css$/,
use: [
{ loader: 'style-laoder', options: { attrs: { id: 'id' } } }
{ loader: 'style-loader', options: { attrs: { id: 'id' } } }
{ loader: 'css-loader' }
]
}
......@@ -227,10 +246,12 @@ A `transform` is a function that can modify the css just before it is loaded int
This function will be called on the css that is about to be loaded and the return value of the function will be loaded into the page instead of the original css.
If the return value of the `transform` function is falsy, the css will not be loaded into the page at all.
> ⚠️ In case you are using ES Module syntax in `tranform.js` then, you **need to transpile** it or otherwise it will throw an `{Error}`.
**webpack.config.js**
```js
{
loader: 'style-loader'
loader: 'style-loader',
options: {
transform: 'path/to/transform.js'
}
......@@ -252,7 +273,7 @@ module.exports = function (css) {
**webpack.config.js**
```js
{
loader: 'style-loader'
loader: 'style-loader',
options: {
transform: 'path/to/conditional.js'
}
......@@ -278,36 +299,64 @@ By default, the style-loader appends `<style>` elements to the end of the style
**webpack.config.js**
```js
{
loader: 'style-loader'
loader: 'style-loader',
options: {
insertAt: 'top'
}
}
```
A new `<style>` element can be inserted before a specific element by passing an object, e.g.
**webpack.config.js**
```js
{
loader: 'style-loader',
options: {
insertAt: {
before: '#id'
}
}
}
```
### `insertInto`
By default, the style-loader inserts the `<style>` elements into the `<head>` tag of the page. If you want the tags to be inserted somewhere else, e.g. into a [ShadowRoot](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot), you can specify a CSS selector for that element here, e.g
By default, the style-loader inserts the `<style>` elements into the `<head>` tag of the page. If you want the tags to be inserted somewhere else you can specify a CSS selector for that element here. If you target an [IFrame](https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement) make sure you have sufficient access rights, the styles will be injected into the content document head.
You can also pass function to override default behavior and insert styles in your container, e.g
**webpack.config.js**
```js
{
loader: 'style-loader',
options: {
insertInto: () => document.querySelector("#root"),
}
}
```
Using function you can insert the styles into a [ShadowRoot](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot), e.g
**webpack.config.js**
```js
{
loader: 'style-loader'
loader: 'style-loader',
options: {
insertAt: '#host::shadow>#root'
insertInto: () => document.querySelector("#root").shadowRoot,
}
}
```
### `singleton`
If defined, the style-loader will reuse a single `<style>` element, instead of adding/removing individual elements for each required module.
If defined, the style-loader will reuse a single `<style></style>` element, instead of adding/removing individual elements for each required module.
> ℹ️ This option is on by default in IE9, which has strict limitations on the number of style tags allowed on a page. You can enable or disable it with the singleton option.
**webpack.config.js**
```js
{
loader: 'style-loader'
loader: 'style-loader',
options: {
singleton: true
}
......@@ -321,7 +370,7 @@ Enable/Disable source map loading
**webpack.config.js**
```js
{
loader: 'style-loader'
loader: 'style-loader',
options: {
sourceMap: true
}
......@@ -335,7 +384,7 @@ If convertToAbsoluteUrls and sourceMaps are both enabled, relative urls will be
**webpack.config.js**
```js
{
loader: 'style-loader'
loader: 'style-loader',
options: {
sourceMap: true,
convertToAbsoluteUrls: true
......
@import "base.css";
body {
border: 1px solid black;
}
\ No newline at end of file
@import "base.css";
.a {
background: blue;
}
\ No newline at end of file
body {
background: green;
}
\ No newline at end of file
body {
border: 3px solid blue;
}
\ No newline at end of file
require("./b.css");
require("./a.css");
require("./c.css");
module.exports = {
module: {
loaders: [
{ test: /\.css$/, loader: "style?insertAt=top!css?sourceMap" }
]
}
}
\ No newline at end of file
......@@ -2,38 +2,95 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var loaderUtils = require("loader-utils"),
path = require("path");
module.exports = function() {};
module.exports.pitch = function(remainingRequest) {
if(this.cacheable) this.cacheable();
var query = loaderUtils.getOptions(this) || {};
var path = require("path");
var loaderUtils = require("loader-utils");
var validateOptions = require('schema-utils');
module.exports = function () {};
module.exports.pitch = function (request) {
if (this.cacheable) this.cacheable();
var options = loaderUtils.getOptions(this) || {};
validateOptions(require('./options.json'), options, 'Style Loader')
options.hmr = typeof options.hmr === 'undefined' ? true : options.hmr;
// The variable is needed, because the function should be inlined.
// If is just stored it in options, JSON.stringify will quote
// the function and it would be just a string at runtime
var insertInto;
if (typeof options.insertInto === "function") {
insertInto = options.insertInto.toString();
}
// We need to check if it a string, or variable will be "undefined"
// and the loader crashes
if (typeof options.insertInto === "string") {
insertInto = '"' + options.insertInto + '"';
}
var hmr = [
// Hot Module Replacement,
"if(module.hot) {",
// When the styles change, update the <style> tags
" module.hot.accept(" + loaderUtils.stringifyRequest(this, "!!" + request) + ", function() {",
" var newContent = require(" + loaderUtils.stringifyRequest(this, "!!" + request) + ");",
"",
" if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];",
"",
" var locals = (function(a, b) {",
" var key, idx = 0;",
"",
" for(key in a) {",
" if(!b || a[key] !== b[key]) return false;",
" idx++;",
" }",
"",
" for(key in b) idx--;",
"",
" return idx === 0;",
" }(content.locals, newContent.locals));",
"",
// This error is caught and not shown and causes a full reload
" if(!locals) throw new Error('Aborting CSS HMR due to changed css-modules locals.');",
"",
" update(newContent);",
" });",
"",
// When the module is disposed, remove the <style> tags
" module.hot.dispose(function() { update(); });",
"}"
].join("\n");
return [
"// style-loader: Adds some css to the DOM by adding a <style> tag",
// Style Loader
// Adds CSS to the DOM by adding a <style> tag
"",
// Load styles
"var content = require(" + loaderUtils.stringifyRequest(this, "!!" + request) + ");",
"",
"// load the styles",
"var content = require(" + loaderUtils.stringifyRequest(this, "!!" + remainingRequest) + ");",
"if(typeof content === 'string') content = [[module.id, content, '']];",
"// Prepare cssTransformation",
"",
// Transform styles",
"var transform;",
query.transform ? "transform = require('" + path.resolve(query.transform) + "');" : "",
"var options = " + JSON.stringify(query),
"var insertInto;",
"",
options.transform ? "transform = require(" + loaderUtils.stringifyRequest(this, "!" + path.resolve(options.transform)) + ");" : "",
"",
"var options = " + JSON.stringify(options),
"",
"options.transform = transform",
"// add the styles to the DOM",
"var update = require(" + loaderUtils.stringifyRequest(this, "!" + path.join(__dirname, "addStyles.js")) + ")(content, options);",
"options.insertInto = " + insertInto + ";",
"",
// Add styles to the DOM
"var update = require(" + loaderUtils.stringifyRequest(this, "!" + path.join(__dirname, "lib", "addStyles.js")) + ")(content, options);",
"",
"if(content.locals) module.exports = content.locals;",
"// Hot Module Replacement",
"if(module.hot) {",
" // When the styles change, update the <style> tags",
" if(!content.locals) {",
" module.hot.accept(" + loaderUtils.stringifyRequest(this, "!!" + remainingRequest) + ", function() {",
" var newContent = require(" + loaderUtils.stringifyRequest(this, "!!" + remainingRequest) + ");",
" if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];",
" update(newContent);",
" });",
" }",
" // When the module is disposed, remove the <style> tags",
" module.hot.dispose(function() { update(); });",
"}"
"",
options.hmr ? hmr : ""
].join("\n");
};
......@@ -3,36 +3,42 @@
Author Tobias Koppers @sokra
*/
function attachTagAttrs(element, attrs) {
function addAttrs (element, attrs) {
Object.keys(attrs).forEach(function (key) {
element.setAttribute(key, attrs[key]);
});
}
module.exports = function addStyleUrl(cssUrl, options) {
if(typeof DEBUG !== "undefined" && DEBUG) {
if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
module.exports = function addStyleUrl (url, options) {
if (typeof DEBUG !== "undefined" && DEBUG) {
if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
}
options = options || {};
options.attrs = typeof options.attrs === "object" ? options.attrs : {};
var styleElement = document.createElement("link");
styleElement.rel = "stylesheet";
styleElement.type = "text/css";