pax_global_header00006660000000000000000000000064133566571120014523gustar00rootroot0000000000000052 comment=80039665d612248535557c41de03a5aa377484a8 style-loader-0.23.1/000077500000000000000000000000001335665711200142125ustar00rootroot00000000000000style-loader-0.23.1/.circleci/000077500000000000000000000000001335665711200160455ustar00rootroot00000000000000style-loader-0.23.1/.circleci/config.yml000066400000000000000000000077211335665711200200440ustar00rootroot00000000000000unit_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: - masterstyle-loader-0.23.1/.gitattributes000066400000000000000000000001111335665711200170760ustar00rootroot00000000000000# Treats the lock file as binary & prevents conflict hell yarn.lock -diffstyle-loader-0.23.1/.github/000077500000000000000000000000001335665711200155525ustar00rootroot00000000000000style-loader-0.23.1/.github/ISSUE_TEMPLATE.md000066400000000000000000000013351335665711200202610ustar00rootroot00000000000000 **Do you want to request a *feature* or report a *bug*?** **What is the current behavior?** **If the current behavior is a bug, please provide the steps to reproduce.** **What is the expected behavior?** **If this is a feature request, what is motivation or use case for changing the behavior?** **Please mention other relevant information such as your webpack version, Node.js version and Operating System.** style-loader-0.23.1/.github/PULL_REQUEST_TEMPLATE.md000066400000000000000000000013141335665711200213520ustar00rootroot00000000000000 **What kind of change does this PR introduce?** **Did you add tests for your changes?** **If relevant, did you update the README?** **Summary** **Does this PR introduce a breaking change?** **Other information** style-loader-0.23.1/.gitignore000066400000000000000000000000361335665711200162010ustar00rootroot00000000000000/node_modules .idea/ /coveragestyle-loader-0.23.1/.npmignore000066400000000000000000000000121335665711200162020ustar00rootroot00000000000000fixtures/ style-loader-0.23.1/CHANGELOG.md000066400000000000000000000220301335665711200160200ustar00rootroot00000000000000# Change Log 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.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)) # [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)) ## [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)) # [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)) # [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)) ## [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)) ## [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)) ## [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)) # [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)) ## [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)) # [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)) ## [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)) ## [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)) # [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)) # [0.17.0](https://github.com/webpack/style-loader/compare/v0.16.1...v0.17.0) (2017-05-01) ### Features * add option.base ([#164](https://github.com/webpack/style-loader/issues/164)) ([e4ac886](https://github.com/webpack/style-loader/commit/e4ac886)) * add option.transform ([#146](https://github.com/webpack/style-loader/issues/146)) ([1c3943f](https://github.com/webpack/style-loader/commit/1c3943f)) ## [0.16.1](https://github.com/webpack/style-loader/compare/v0.16.0...v0.16.1) (2017-03-28) ### Bug Fixes * negative refs ([#122](https://github.com/webpack/style-loader/issues/122)) ([f6f577a](https://github.com/webpack/style-loader/commit/f6f577a)) # [0.16.0](https://github.com/webpack/style-loader/compare/v0.15.0...v0.16.0) (2017-03-22) ### Bug Fixes * **addStyles:** update for test for old IE versions ([#196](https://github.com/webpack/style-loader/issues/196)) ([1f68495](https://github.com/webpack/style-loader/commit/1f68495)) ### Features * Set custom attributes for tag in url mode ([#198](https://github.com/webpack/style-loader/issues/198)) ([2c4f427](https://github.com/webpack/style-loader/commit/2c4f427)) # [0.15.0](https://github.com/webpack/style-loader/compare/v0.14.1...v0.15.0) (2017-03-21) ### Bug Fixes * match parens recursively on URLs to not fix embeded calls ([#192](https://github.com/webpack/style-loader/issues/192)) ([71e0908](https://github.com/webpack/style-loader/commit/71e0908)) ### Features * add insertInto option ([#135](https://github.com/webpack/style-loader/issues/135)) ([6636868](https://github.com/webpack/style-loader/commit/6636868)) ## [0.14.1](https://github.com/webpack/style-loader/compare/v0.14.0...v0.14.1) (2017-03-15) ### Bug Fixes * syntax error in IE10 and below because of `const` keyword ([#190](https://github.com/webpack/style-loader/issues/190)) ([01080cf](https://github.com/webpack/style-loader/commit/01080cf)) # [0.14.0](https://github.com/webpack/style-loader/compare/v0.13.1...v0.14.0) (2017-03-15) ### Bug Fixes * Adds type attr. to the generated link element ([2a2f261](https://github.com/webpack/style-loader/commit/2a2f261)) * **fixUrls:** add param to fix relative urls ([#186](https://github.com/webpack/style-loader/issues/186)) ([19959ee](https://github.com/webpack/style-loader/commit/19959ee)) * **usable:** Export locals if available([#128](https://github.com/webpack/style-loader/issues/128)) ([e280cb6](https://github.com/webpack/style-loader/commit/e280cb6)) ### Features * **tag-attribute:** Add support for custom tag attribute ([995f3de](https://github.com/webpack/style-loader/commit/995f3de)) style-loader-0.23.1/LICENSE000066400000000000000000000020571335665711200152230ustar00rootroot00000000000000Copyright JS Foundation and other contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. style-loader-0.23.1/README.md000066400000000000000000000305151335665711200154750ustar00rootroot00000000000000[![npm][npm]][npm-url] [![node][node]][node-url] [![deps][deps]][deps-url] [![chat][chat]][chat-url]

Style Loader

Adds CSS to the DOM by injecting a <style> tag

Install

```bash npm install style-loader --save-dev ```

Usage

It's recommended to combine `style-loader` with the [`css-loader`](https://github.com/webpack/css-loader) **component.js** ```js import style from './file.css' ``` **webpack.config.js** ```js { module: { rules: [ { test: /\.css$/, use: [ { loader: "style-loader" }, { loader: "css-loader" } ] } ] } } ``` #### `Locals (CSS Modules)` When using [local scoped CSS](https://github.com/webpack/css-loader#css-scope) the module exports the generated identifiers (locals). **component.js** ```js import style from './file.css' style.className === "z849f98ca812" ``` ### `Url` It's also possible to add a URL `` instead of inlining the CSS `{String}` with `` tag. ```js import url from 'file.css' ``` **webpack.config.js** ```js { module: { rules: [ { test: /\.css$/, use: [ { loader: "style-loader/url" }, { loader: "file-loader" } ] } ] } } ``` ```html ``` > ℹ️ 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** ```js { module: { rules: [ { test: /\.css$/, use: [ { loader: "style-loader" }, { loader: "css-loader" }, ], }, { test: /\.useable\.css$/, use: [ { loader: "style-loader/useable" }, { loader: "css-loader" }, ], }, ], }, } ``` #### `Reference Counter API` **component.js** ```js import style from './file.css' style.use(); // = style.ref(); 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`. > ⚠️ Behavior is undefined when `unuse`/`unref` is called more often than `use`/`ref`. Don't do that.

Options

|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 ``| |**`transform`** |`{Function}`|`false`|Transform/Conditionally load CSS by passing a transform/condition function| |**`insertAt`**|`{String\|Object}`|`bottom`|Inserts `` at the given position| |**`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` 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` This setting is primarily used as a workaround for [css clashes](https://github.com/webpack-contrib/style-loader/issues/163) when using one or more [DllPlugin](https://robertknight.github.io/posts/webpack-dll-plugins/)'s. `base` allows you to prevent either the *app*'s css (or *DllPlugin2*'s css) from overwriting *DllPlugin1*'s css by specifying a css module id base which is greater than the range used by *DllPlugin1* e.g.: **webpack.dll1.config.js** ```js { test: /\.css$/, use: [ 'style-loader', 'css-loader' ] } ``` **webpack.dll2.config.js** ```js { test: /\.css$/, use: [ { loader: 'style-loader', options: { base: 1000 } }, 'css-loader' ] } ``` **webpack.app.config.js** ``` { test: /\.css$/, use: [ { loader: 'style-loader', options: { base: 2000 } }, 'css-loader' ] } ``` ### `attrs` If defined, style-loader will attach given attributes with their values on ` ``` #### `Url` **component.js** ```js import link from './file.css' ``` **webpack.config.js** ```js { test: /\.css$/, use: [ { loader: 'style-loader/url', options: { attrs: { id: 'id' } } } { loader: 'file-loader' } ] } ``` ### `transform` A `transform` is a function that can modify the css just before it is loaded into the page by the style-loader. 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', options: { transform: 'path/to/transform.js' } } ``` **transform.js** ```js module.exports = function (css) { // Here we can change the original css const transformed = css.replace('.classNameA', '.classNameB') return transformed } ``` #### `Conditional` **webpack.config.js** ```js { loader: 'style-loader', options: { transform: 'path/to/conditional.js' } } ``` **conditional.js** ```js module.exports = function (css) { // If the condition is matched load [and transform] the CSS if (css.includes('something I want to check')) { return css; } // If a falsy value is returned, the CSS won't be loaded return false } ``` ### `insertAt` By default, the style-loader appends `` 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', options: { singleton: true } } ``` ### `sourceMap` Enable/Disable source map loading **webpack.config.js** ```js { loader: 'style-loader', options: { sourceMap: true } } ``` ### `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


Juho Vepsäläinen

Joshua Wiens

Artem Sapegin

Michael Ciniawsky

Alexander Krasnoyarov

Tobias Koppers

Kees Kluskens
[npm]: https://img.shields.io/npm/v/style-loader.svg [npm-url]: https://npmjs.com/package/style-loader [node]: https://img.shields.io/node/v/style-loader.svg [node-url]: https://nodejs.org [deps]: https://david-dm.org/webpack/style-loader.svg [deps-url]: https://david-dm.org/webpack/file-loader [chat]: https://badges.gitter.im/webpack/webpack.svg [chat-url]: https://gitter.im/webpack/webpack style-loader-0.23.1/index.js000066400000000000000000000056321335665711200156650ustar00rootroot00000000000000/* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ 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 `, existingStyle = ``, checkValue = '
check
', rootDir = path.resolve(__dirname + "/../") + "/", jsdomHtml = [ "", "", existingStyle, "", "", "
", checkValue, "
", "