From 3cf3c9268c804506896114af3899f59debf70809 Mon Sep 17 00:00:00 2001 From: huang <1724659546@qq.com> Date: Fri, 19 Sep 2025 14:53:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 1 - node_modules/.package-lock.json | 16 + node_modules/style-loader/LICENSE | 20 + node_modules/style-loader/README.md | 1270 +++++++++++++++++ node_modules/style-loader/dist/cjs.js | 4 + node_modules/style-loader/dist/index.js | 151 ++ node_modules/style-loader/dist/options.json | 45 + .../dist/runtime/injectStylesIntoLinkTag.js | 29 + .../dist/runtime/injectStylesIntoStyleTag.js | 84 ++ .../dist/runtime/insertBySelector.js | 34 + .../dist/runtime/insertStyleElement.js | 10 + .../dist/runtime/isEqualLocals.js | 28 + .../style-loader/dist/runtime/isOldIE.js | 17 + .../runtime/setAttributesWithAttributes.js | 13 + .../setAttributesWithAttributesAndNonce.js | 9 + .../runtime/setAttributesWithoutAttributes.js | 10 + .../dist/runtime/singletonStyleDomAPI.js | 86 ++ .../style-loader/dist/runtime/styleDomAPI.js | 61 + .../dist/runtime/styleTagTransform.js | 14 + node_modules/style-loader/dist/utils.js | 191 +++ node_modules/style-loader/package.json | 85 ++ package-lock.json | 20 +- package.json | 22 +- src/main.js | 4 - webpack.config.js | 17 +- 25 files changed, 2221 insertions(+), 20 deletions(-) create mode 100644 node_modules/style-loader/LICENSE create mode 100644 node_modules/style-loader/README.md create mode 100644 node_modules/style-loader/dist/cjs.js create mode 100644 node_modules/style-loader/dist/index.js create mode 100644 node_modules/style-loader/dist/options.json create mode 100644 node_modules/style-loader/dist/runtime/injectStylesIntoLinkTag.js create mode 100644 node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js create mode 100644 node_modules/style-loader/dist/runtime/insertBySelector.js create mode 100644 node_modules/style-loader/dist/runtime/insertStyleElement.js create mode 100644 node_modules/style-loader/dist/runtime/isEqualLocals.js create mode 100644 node_modules/style-loader/dist/runtime/isOldIE.js create mode 100644 node_modules/style-loader/dist/runtime/setAttributesWithAttributes.js create mode 100644 node_modules/style-loader/dist/runtime/setAttributesWithAttributesAndNonce.js create mode 100644 node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js create mode 100644 node_modules/style-loader/dist/runtime/singletonStyleDomAPI.js create mode 100644 node_modules/style-loader/dist/runtime/styleDomAPI.js create mode 100644 node_modules/style-loader/dist/runtime/styleTagTransform.js create mode 100644 node_modules/style-loader/dist/utils.js create mode 100644 node_modules/style-loader/package.json diff --git a/index.html b/index.html index 5f5b8938..3f02d164 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,6 @@ 猪场管理系统 -
diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 2e0f8706..eb6bd76b 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -9333,6 +9333,22 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/style-loader": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/style-loader/-/style-loader-4.0.0.tgz", + "integrity": "sha512-1V4WqhhZZgjVAVJyt7TdDPZoPBPNHbekX4fWnCJL1yQukhCeZhJySUL+gL9y6sNdN95uEOS83Y55SqHcP7MzLA==", + "dev": true, + "engines": { + "node": ">= 18.12.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.27.0" + } + }, "node_modules/stylehacks": { "version": "5.1.1", "resolved": "https://registry.npmmirror.com/stylehacks/-/stylehacks-5.1.1.tgz", diff --git a/node_modules/style-loader/LICENSE b/node_modules/style-loader/LICENSE new file mode 100644 index 00000000..8c11fc72 --- /dev/null +++ b/node_modules/style-loader/LICENSE @@ -0,0 +1,20 @@ +Copyright 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. diff --git a/node_modules/style-loader/README.md b/node_modules/style-loader/README.md new file mode 100644 index 00000000..bc50ea8f --- /dev/null +++ b/node_modules/style-loader/README.md @@ -0,0 +1,1270 @@ +
+ + + +

Style Loader

+
+ +[![npm][npm]][npm-url] +[![node][node]][node-url] +[![tests][tests]][tests-url] +[![coverage][cover]][cover-url] +[![discussion][discussion]][discussion-url] +[![size][size]][size-url] + +# style-loader + +Inject CSS into the DOM. + +## Getting Started + +To begin, you'll need to install `style-loader`: + +```console +npm install --save-dev style-loader +``` + +or + +```console +yarn add -D style-loader +``` + +or + +```console +pnpm add -D style-loader +``` + +It's recommended to combine `style-loader` with the [`css-loader`](https://github.com/webpack-contrib/css-loader) + +Then add the loader to your `webpack` config. For example: + +**style.css** + +```css +body { + background: green; +} +``` + +**component.js** + +```js +import "./style.css"; +``` + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + use: ["style-loader", "css-loader"], + }, + ], + }, +}; +``` + +## Security Warning + +This loader is primarily meant for development. The default settings are not safe for production environments. See the [recommended example configuration](#recommend) and the section on [nonces](#nonce) for details. + +## Options + +- [**`injectType`**](#injecttype) +- [**`attributes`**](#attributes) +- [**`insert`**](#insert) +- [**`styleTagTransform`**](#styleTagTransform) +- [**`base`**](#base) +- [**`esModule`**](#esmodule) + +### `injectType` + +Type: + +```ts +type injectType = + | "styleTag" + | "singletonStyleTag" + | "autoStyleTag" + | "lazyStyleTag" + | "lazySingletonStyleTag" + | "lazyAutoStyleTag" + | "linkTag"; +``` + +Default: `styleTag` + +Allows to setup how styles will be injected into the DOM. + +Possible values: + +#### `styleTag` + +Automatically injects styles into the DOM using multiple ``. It is **default** behaviour. + +**component.js** + +```js +import "./styles.css"; +``` + +Example with Locals (CSS Modules): + +**component-with-css-modules.js** + +```js +import * as styles from "./styles.css"; + +const divElement = document.createElement("div"); +divElement.className = styles["my-class"]; +``` + +All local variables (class names) are exported as named exports. To achieve this behaviour you also have to setup `modules` option for `css-loader`. For more information consult with `css-loader` [`documentation`](https://github.com/webpack-contrib/css-loader). + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + use: [ + // The `injectType` option can be avoided because it is default behaviour + { loader: "style-loader", options: { injectType: "styleTag" } }, + { + loader: "css-loader", + // Uncomment it if you want to use CSS modules + // options: { modules: true } + }, + ], + }, + ], + }, +}; +``` + +The loader inject styles like: + +```html + + +``` + +#### `singletonStyleTag` + +Automatically injects styles into the DOM using one ``. + +> **Warning** +> +> Source maps do not work. + +**component.js** + +```js +import "./styles.css"; +``` + +**component-with-css-modules.js** + +```js +import * as styles from "./styles.css"; + +const divElement = document.createElement("div"); +divElement.className = styles["my-class"]; +``` + +All local variables (class names) are exported as named exports. To achieve this behaviour you also have to setup `modules` option for `css-loader`. For more information consult with `css-loader` [`documentation`](https://github.com/webpack-contrib/css-loader). + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + use: [ + { + loader: "style-loader", + options: { injectType: "singletonStyleTag" }, + }, + { + loader: "css-loader", + // Uncomment it if you want to use CSS modules + // options: { modules: true } + }, + ], + }, + ], + }, +}; +``` + +The loader inject styles like: + +```html + +``` + +#### `autoStyleTag` + +Works the same as a [`styleTag`](#styleTag), but if the code is executed in IE6-9, turns on the [`singletonStyleTag`](#singletonStyleTag) mode. + +#### `lazyStyleTag` + +Injects styles into the DOM using multiple `` on demand. +We recommend following `.lazy.css` naming convention for lazy styles and the `.css` for basic `style-loader` usage (similar to other file types, i.e. `.lazy.less` and `.less`). +When you `lazyStyleTag` value the `style-loader` injects the styles lazily making them useable on-demand via `style.use()` / `style.unuse()`. + +> ⚠️ Behavior is undefined when `unuse` is called more often than `use`. Don't do that. + +**component.js** + +```js +import styles from "./styles.lazy.css"; + +styles.use(); +// For removing styles you can use +// styles.unuse(); +``` + +**component-with-css-modules.js** + +```js +import styles, { "my-class" as myClass } from "./styles.lazy.css"; + +styles.use(); + +const divElement = document.createElement("div"); +divElement.className = myClass; +``` + +All local variables (class names) are exported as named exports. To achieve this behaviour you also have to setup `modules` option for `css-loader`. For more information consult with `css-loader` [`documentation`](https://github.com/webpack-contrib/css-loader). + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + exclude: /\.lazy\.css$/i, + use: ["style-loader", "css-loader"], + }, + { + test: /\.lazy\.css$/i, + use: [ + { loader: "style-loader", options: { injectType: "lazyStyleTag" } }, + { + loader: "css-loader", + // Uncomment it if you want to use CSS modules + // options: { modules: true } + }, + ], + }, + ], + }, +}; +``` + +The loader inject styles like: + +```html + + +``` + +#### `lazySingletonStyleTag` + +Injects styles into the DOM using one `` on demand. +We recommend following `.lazy.css` naming convention for lazy styles and the `.css` for basic `style-loader` usage (similar to other file types, i.e. `.lazy.less` and `.less`). +When you `lazySingletonStyleTag` value the `style-loader` injects the styles lazily making them useable on-demand via `style.use()` / `style.unuse()`. + +> ⚠️ Source maps do not work. + +> ⚠️ Behavior is undefined when `unuse` is called more often than `use`. Don't do that. + +**component.js** + +```js +import styles from "./styles.css"; + +styles.use(); +// For removing styles you can use +// styles.unuse(); +``` + +**component-with-css-modules.js** + +```js +import styles, { "my-class" as myClass } from "./styles.lazy.css"; + +styles.use(); + +const divElement = document.createElement("div"); +divElement.className = myClass; +``` + +All local variables (class names) are exported as named exports. To achieve this behaviour you also have to setup `modules` option for `css-loader`. For more information consult with `css-loader` [`documentation`](https://github.com/webpack-contrib/css-loader). + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + exclude: /\.lazy\.css$/i, + use: ["style-loader", "css-loader"], + }, + { + test: /\.lazy\.css$/i, + use: [ + { + loader: "style-loader", + options: { injectType: "lazySingletonStyleTag" }, + }, + { + loader: "css-loader", + // Uncomment it if you want to use CSS modules + // options: { modules: true } + }, + ], + }, + ], + }, +}; +``` + +The loader generate this: + +```html + +``` + +#### `lazyAutoStyleTag` + +Works the same as a [`lazyStyleTag`](#lazyStyleTag), but if the code is executed in IE6-9, turns on the [`lazySingletonStyleTag`](#lazySingletonStyleTag) mode. + +#### `linkTag` + +Injects styles into the DOM using multiple `` . + +> ℹ️ The loader will dynamically insert the `` tag at runtime via JavaScript. You should use [MiniCssExtractPlugin](https://webpack.js.org/plugins/mini-css-extract-plugin/) if you want to include a static ``. + +```js +import "./styles.css"; +import "./other-styles.css"; +``` + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.link\.css$/i, + use: [ + { loader: "style-loader", options: { injectType: "linkTag" } }, + { loader: "file-loader" }, + ], + }, + ], + }, +}; +``` + +The loader generate this: + +```html + + +``` + +### `attributes` + +Type: + +```ts +type attributes = HTMLAttributes; +``` + +Default: `{}` + +If defined, the `style-loader` will attach given attributes with their values on ` +``` + +### `insert` + +Type: + +```ts +type insert = string; +``` + +Default: `head` + +By default, the `style-loader` appends `` and works faster. + +> **Warning** +> +> Do not use together `style-loader` and `mini-css-extract-plugin`. + +**webpack.config.js** + +```js +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); +const devMode = process.env.NODE_ENV !== "production"; + +module.exports = { + module: { + rules: [ + { + test: /\.(sa|sc|c)ss$/, + use: [ + devMode ? "style-loader" : MiniCssExtractPlugin.loader, + "css-loader", + "postcss-loader", + "sass-loader", + ], + }, + ], + }, + plugins: [].concat(devMode ? [] : [new MiniCssExtractPlugin()]), +}; +``` + +### Named export for CSS Modules + +> **Warning** +> +> It is not allowed to use JavaScript reserved words in css class names. + +> **Warning** +> +> Options `esModule` and `modules.namedExport` in `css-loader` should be enabled (by default for `css-loader@7` it is true). + +**styles.css** + +```css +.fooBaz { + color: red; +} +.bar { + color: blue; +} +.my-class { + color: green; +} +``` + +**index.js** + +```js +import { fooBaz, bar, "my-class" as myClass } from "./styles.css"; + +console.log(fooBaz, bar, myClass); +``` + +Or: + +**index.js** + +```js +import * as styles from "./styles.css"; + +console.log(styles.fooBaz, styles.bar, styles["my-class"]); +``` + +You can enable a ES module named export using: + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/, + use: [ + { + loader: "style-loader", + }, + { + loader: "css-loader", + options: { + modules: { + namedExport: true, + }, + }, + }, + ], + }, + ], + }, +}; +``` + +### Source maps + +The loader automatically inject source maps when previous loader emit them. +Therefore, to generate source maps, set the `sourceMap` option to `true` for the previous loader. + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + use: [ + "style-loader", + { loader: "css-loader", options: { sourceMap: true } }, + ], + }, + ], + }, +}; +``` + +### Nonce + +If you are using a [Content Security Policy](https://www.w3.org/TR/CSP3/) (CSP), the injected code will usually be blocked. A workaround is to use a nonce. Note, however, that using a nonce significantly reduces the protection provided by the CSP. You can read more about the security impact in [the specification](https://www.w3.org/TR/CSP3/#security-considerations). The better solution is not to use this loader in production. + +There are two ways to work with `nonce`: + +- using the `attributes` option +- using the `__webpack_nonce__` variable + +> **Warning** +> +> the `attributes` option takes precedence over the `__webpack_nonce__` variable + +#### `attributes` + +**component.js** + +```js +import "./style.css"; +``` + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + use: [ + { + loader: "style-loader", + options: { + attributes: { + nonce: "12345678", + }, + }, + }, + "css-loader", + ], + }, + ], + }, +}; +``` + +The loader generate: + +```html + +``` + +#### `__webpack_nonce__` + +**create-nonce.js** + +```js +__webpack_nonce__ = "12345678"; +``` + +**component.js** + +```js +import "./create-nonce.js"; +import "./style.css"; +``` + +Alternative example for `require`: + +**component.js** + +```js +__webpack_nonce__ = "12345678"; + +require("./style.css"); +``` + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + use: ["style-loader", "css-loader"], + }, + ], + }, +}; +``` + +The loader generate: + +```html + +``` + +#### Insert styles at top + +Insert styles at top of `head` tag. + +**insert-function.js** + +```js +function insertAtTop(element) { + var parent = document.querySelector("head"); + var lastInsertedElement = window._lastElementInsertedByStyleLoader; + + if (!lastInsertedElement) { + parent.insertBefore(element, parent.firstChild); + } else if (lastInsertedElement.nextSibling) { + parent.insertBefore(element, lastInsertedElement.nextSibling); + } else { + parent.appendChild(element); + } + + window._lastElementInsertedByStyleLoader = element; +} + +module.exports = insertAtTop; +``` + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + use: [ + { + loader: "style-loader", + options: { + insert: require.resolve("./insert-function.js"), + }, + }, + "css-loader", + ], + }, + ], + }, +}; +``` + +#### Insert styles before target element + +Inserts styles before `#id` element. + +**insert-function.js** + +```js +function insertBeforeAt(element) { + const parent = document.querySelector("head"); + const target = document.querySelector("#id"); + + const lastInsertedElement = window._lastElementInsertedByStyleLoader; + + if (!lastInsertedElement) { + parent.insertBefore(element, target); + } else if (lastInsertedElement.nextSibling) { + parent.insertBefore(element, lastInsertedElement.nextSibling); + } else { + parent.appendChild(element); + } + + window._lastElementInsertedByStyleLoader = element; +} + +module.exports = insertBeforeAt; +``` + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + use: [ + { + loader: "style-loader", + options: { + insert: require.resolve("./insert-function.js"), + }, + }, + "css-loader", + ], + }, + ], + }, +}; +``` + +#### Custom Elements (Shadow DOM) + +You can define custom target for your styles for the `lazyStyleTag` type. + +**insert-function.js** + +```js +function insertIntoTarget(element, options) { + var parent = options.target || document.head; + + parent.appendChild(element); +} + +module.exports = insertIntoTarget; +``` + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + use: [ + { + loader: "style-loader", + options: { + injectType: "lazyStyleTag", + // Do not forget that this code will be used in the browser and + // not all browsers support latest ECMA features like `let`, `const`, `arrow function expression` and etc, + // we recommend use only ECMA 5 features, + // but it is depends what browsers you want to support + insert: require.resolve("./insert-function.js"), + }, + }, + "css-loader", + ], + }, + ], + }, +}; +``` + +Insert styles to the provided element or to the `head` tag if target isn't provided. + +**custom-square.css** + +```css +div { + width: 50px; + height: 50px; + background-color: red; +} +``` + +**custom-square.js** + +```js +import customSquareStyles from "./custom-square.css"; + +class CustomSquare extends HTMLElement { + constructor() { + super(); + + this.attachShadow({ mode: "open" }); + + const divElement = document.createElement("div"); + + divElement.textContent = "Text content."; + + this.shadowRoot.appendChild(divElement); + + customSquareStyles.use({ target: this.shadowRoot }); + + // You can override injected styles + const bgPurple = new CSSStyleSheet(); + const width = this.getAttribute("w"); + const height = this.getAttribute("h"); + + bgPurple.replace(`div { width: ${width}px; height: ${height}px; }`); + + this.shadowRoot.adoptedStyleSheets = [bgPurple]; + + // `divElement` will have `100px` width, `100px` height and `red` background color + } +} + +customElements.define("custom-square", CustomSquare); + +export default CustomSquare; +``` + +## Contributing + +Please take a moment to read our contributing guidelines if you haven't yet done so. + +[CONTRIBUTING](./.github/CONTRIBUTING.md) + +## License + +[MIT](./LICENSE) + +[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 +[tests]: https://github.com/webpack-contrib/style-loader/workflows/style-loader/badge.svg +[tests-url]: https://github.com/webpack-contrib/style-loader/actions +[cover]: https://codecov.io/gh/webpack-contrib/style-loader/branch/master/graph/badge.svg +[cover-url]: https://codecov.io/gh/webpack-contrib/style-loader +[discussion]: https://img.shields.io/github/discussions/webpack/webpack +[discussion-url]: https://github.com/webpack/webpack/discussions +[size]: https://packagephobia.now.sh/badge?p=style-loader +[size-url]: https://packagephobia.now.sh/result?p=style-loader diff --git a/node_modules/style-loader/dist/cjs.js b/node_modules/style-loader/dist/cjs.js new file mode 100644 index 00000000..65f9fc86 --- /dev/null +++ b/node_modules/style-loader/dist/cjs.js @@ -0,0 +1,4 @@ +"use strict"; + +const loader = require("./index"); +module.exports = loader.default; \ No newline at end of file diff --git a/node_modules/style-loader/dist/index.js b/node_modules/style-loader/dist/index.js new file mode 100644 index 00000000..0e53b7fe --- /dev/null +++ b/node_modules/style-loader/dist/index.js @@ -0,0 +1,151 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _path = _interopRequireDefault(require("path")); +var _utils = require("./utils"); +var _options = _interopRequireDefault(require("./options.json")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +// eslint-disable-next-line consistent-return +const loader = function loader(content) { + if (this._compiler && this._compiler.options && this._compiler.options.experiments && this._compiler.options.experiments.css && this._module && (this._module.type === "css" || this._module.type === "css/global" || this._module.type === "css/module" || this._module.type === "css/auto")) { + return content; + } +}; +loader.pitch = function pitch(request) { + if (this._compiler && this._compiler.options && this._compiler.options.experiments && this._compiler.options.experiments.css && this._module && (this._module.type === "css" || this._module.type === "css/global" || this._module.type === "css/module" || this._module.type === "css/auto")) { + this.emitWarning(new Error('You can\'t use `experiments.css` (`experiments.futureDefaults` enable built-in CSS support by default) and `style-loader` together, please set `experiments.css` to `false` or set `{ type: "javascript/auto" }` for rules with `style-loader` in your webpack config (now `style-loader` does nothing).')); + return; + } + const options = this.getOptions(_options.default); + const injectType = options.injectType || "styleTag"; + const esModule = typeof options.esModule !== "undefined" ? options.esModule : true; + const runtimeOptions = {}; + if (options.attributes) { + runtimeOptions.attributes = options.attributes; + } + if (options.base) { + runtimeOptions.base = options.base; + } + const insertType = options.insert && _path.default.isAbsolute(options.insert) ? "module-path" : "selector"; + switch (injectType) { + case "linkTag": + { + const hmrCode = this.hot ? (0, _utils.getLinkHmrCode)(esModule, this, request) : ""; + + // eslint-disable-next-line consistent-return + return ` + ${(0, _utils.getImportLinkAPICode)(esModule, this)} + ${(0, _utils.getImportInsertBySelectorCode)(esModule, this, insertType, options)} + ${(0, _utils.getImportLinkContentCode)(esModule, this, request)} + ${esModule ? "" : `content = content.__esModule ? content.default : content;`} + +var options = ${JSON.stringify(runtimeOptions)}; + +${(0, _utils.getInsertOptionCode)(insertType, options)} + +var update = API(content, options); + +${hmrCode} + +${esModule ? "export default {}" : ""}`; + } + case "lazyStyleTag": + case "lazyAutoStyleTag": + case "lazySingletonStyleTag": + { + const isSingleton = injectType === "lazySingletonStyleTag"; + const isAuto = injectType === "lazyAutoStyleTag"; + const hmrCode = this.hot ? (0, _utils.getStyleHmrCode)(esModule, this, request, true) : ""; + + // eslint-disable-next-line consistent-return + return ` + var exported = {}; + + ${(0, _utils.getImportStyleAPICode)(esModule, this)} + ${(0, _utils.getImportStyleDomAPICode)(esModule, this, isSingleton, isAuto)} + ${(0, _utils.getImportInsertBySelectorCode)(esModule, this, insertType, options)} + ${(0, _utils.getSetAttributesCode)(esModule, this, options)} + ${(0, _utils.getImportInsertStyleElementCode)(esModule, this)} + ${(0, _utils.getStyleTagTransformFnCode)(esModule, this, options, isSingleton)} + ${(0, _utils.getImportStyleContentCode)(esModule, this, request)} + ${isAuto ? (0, _utils.getImportIsOldIECode)(esModule, this) : ""} + ${esModule ? `if (content && content.locals) { + exported.locals = content.locals; + } + ` : `content = content.__esModule ? content.default : content; + + exported.locals = content.locals || {};`} + +var refs = 0; +var update; +var options = ${JSON.stringify(runtimeOptions)}; + +${(0, _utils.getStyleTagTransformFn)(options, isSingleton)}; +options.setAttributes = setAttributes; +${(0, _utils.getInsertOptionCode)(insertType, options)} +options.domAPI = ${(0, _utils.getdomAPI)(isAuto)}; +options.insertStyleElement = insertStyleElement; + +exported.use = function(insertOptions) { + options.options = insertOptions || {}; + + if (!(refs++)) { + update = API(content, options); + } + + return exported; +}; +exported.unuse = function() { + if (refs > 0 && !--refs) { + update(); + update = null; + } +}; + +${hmrCode} + +${(0, _utils.getExportLazyStyleCode)(esModule, this, request)} +`; + } + case "styleTag": + case "autoStyleTag": + case "singletonStyleTag": + default: + { + const isSingleton = injectType === "singletonStyleTag"; + const isAuto = injectType === "autoStyleTag"; + const hmrCode = this.hot ? (0, _utils.getStyleHmrCode)(esModule, this, request, false) : ""; + + // eslint-disable-next-line consistent-return + return ` + ${(0, _utils.getImportStyleAPICode)(esModule, this)} + ${(0, _utils.getImportStyleDomAPICode)(esModule, this, isSingleton, isAuto)} + ${(0, _utils.getImportInsertBySelectorCode)(esModule, this, insertType, options)} + ${(0, _utils.getSetAttributesCode)(esModule, this, options)} + ${(0, _utils.getImportInsertStyleElementCode)(esModule, this)} + ${(0, _utils.getStyleTagTransformFnCode)(esModule, this, options, isSingleton)} + ${(0, _utils.getImportStyleContentCode)(esModule, this, request)} + ${isAuto ? (0, _utils.getImportIsOldIECode)(esModule, this) : ""} + ${esModule ? "" : `content = content.__esModule ? content.default : content;`} + +var options = ${JSON.stringify(runtimeOptions)}; + +${(0, _utils.getStyleTagTransformFn)(options, isSingleton)}; +options.setAttributes = setAttributes; +${(0, _utils.getInsertOptionCode)(insertType, options)} +options.domAPI = ${(0, _utils.getdomAPI)(isAuto)}; +options.insertStyleElement = insertStyleElement; + +var update = API(content, options); + +${hmrCode} + +${(0, _utils.getExportStyleCode)(esModule, this, request)} +`; + } + } +}; +var _default = exports.default = loader; \ No newline at end of file diff --git a/node_modules/style-loader/dist/options.json b/node_modules/style-loader/dist/options.json new file mode 100644 index 00000000..1ecd6866 --- /dev/null +++ b/node_modules/style-loader/dist/options.json @@ -0,0 +1,45 @@ +{ + "title": "Style Loader options", + "type": "object", + "properties": { + "injectType": { + "description": "Allows to setup how styles will be injected into DOM.", + "link": "https://github.com/webpack-contrib/style-loader#injecttype", + "enum": [ + "styleTag", + "singletonStyleTag", + "autoStyleTag", + "lazyStyleTag", + "lazySingletonStyleTag", + "lazyAutoStyleTag", + "linkTag" + ] + }, + "attributes": { + "description": "Adds custom attributes to tag.", + "link": "https://github.com/webpack-contrib/style-loader#attributes", + "type": "object" + }, + "insert": { + "description": "Inserts `