source: frontend/node_modules/style-loader/dist/index.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 6.3 KB
RevLine 
[9af201e]1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7var _path = _interopRequireDefault(require("path"));
8var _utils = require("./utils");
9var _options = _interopRequireDefault(require("./options.json"));
10function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11// eslint-disable-next-line consistent-return
12const loader = function loader(content) {
13 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")) {
14 return content;
15 }
16};
17loader.pitch = function pitch(request) {
18 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")) {
19 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).'));
20 return;
21 }
22 const options = this.getOptions(_options.default);
23 const injectType = options.injectType || "styleTag";
24 const esModule = typeof options.esModule !== "undefined" ? options.esModule : true;
25 const runtimeOptions = {};
26 if (options.attributes) {
27 runtimeOptions.attributes = options.attributes;
28 }
29 if (options.base) {
30 runtimeOptions.base = options.base;
31 }
32 const insertType = typeof options.insert === "function" ? "function" : options.insert && _path.default.isAbsolute(options.insert) ? "module-path" : "selector";
33 const styleTagTransformType = typeof options.styleTagTransform === "function" ? "function" : options.styleTagTransform && _path.default.isAbsolute(options.styleTagTransform) ? "module-path" : "default";
34 switch (injectType) {
35 case "linkTag":
36 {
37 const hmrCode = this.hot ? (0, _utils.getLinkHmrCode)(esModule, this, request) : "";
38
39 // eslint-disable-next-line consistent-return
40 return `
41 ${(0, _utils.getImportLinkAPICode)(esModule, this)}
42 ${(0, _utils.getImportInsertBySelectorCode)(esModule, this, insertType, options)}
43 ${(0, _utils.getImportLinkContentCode)(esModule, this, request)}
44 ${esModule ? "" : `content = content.__esModule ? content.default : content;`}
45
46var options = ${JSON.stringify(runtimeOptions)};
47
48${(0, _utils.getInsertOptionCode)(insertType, options)}
49
50var update = API(content, options);
51
52${hmrCode}
53
54${esModule ? "export default {}" : ""}`;
55 }
56 case "lazyStyleTag":
57 case "lazyAutoStyleTag":
58 case "lazySingletonStyleTag":
59 {
60 const isSingleton = injectType === "lazySingletonStyleTag";
61 const isAuto = injectType === "lazyAutoStyleTag";
62 const hmrCode = this.hot ? (0, _utils.getStyleHmrCode)(esModule, this, request, true) : "";
63
64 // eslint-disable-next-line consistent-return
65 return `
66 var exported = {};
67
68 ${(0, _utils.getImportStyleAPICode)(esModule, this)}
69 ${(0, _utils.getImportStyleDomAPICode)(esModule, this, isSingleton, isAuto)}
70 ${(0, _utils.getImportInsertBySelectorCode)(esModule, this, insertType, options)}
71 ${(0, _utils.getSetAttributesCode)(esModule, this, options)}
72 ${(0, _utils.getImportInsertStyleElementCode)(esModule, this)}
73 ${(0, _utils.getStyleTagTransformFnCode)(esModule, this, options, isSingleton, styleTagTransformType)}
74 ${(0, _utils.getImportStyleContentCode)(esModule, this, request)}
75 ${isAuto ? (0, _utils.getImportIsOldIECode)(esModule, this) : ""}
76 ${esModule ? `if (content && content.locals) {
77 exported.locals = content.locals;
78 }
79 ` : `content = content.__esModule ? content.default : content;
80
81 exported.locals = content.locals || {};`}
82
83var refs = 0;
84var update;
85var options = ${JSON.stringify(runtimeOptions)};
86
87${(0, _utils.getStyleTagTransformFn)(options, isSingleton)};
88options.setAttributes = setAttributes;
89${(0, _utils.getInsertOptionCode)(insertType, options)}
90options.domAPI = ${(0, _utils.getdomAPI)(isAuto)};
91options.insertStyleElement = insertStyleElement;
92
93exported.use = function(insertOptions) {
94 options.options = insertOptions || {};
95
96 if (!(refs++)) {
97 update = API(content, options);
98 }
99
100 return exported;
101};
102exported.unuse = function() {
103 if (refs > 0 && !--refs) {
104 update();
105 update = null;
106 }
107};
108
109${hmrCode}
110
111${(0, _utils.getExportLazyStyleCode)(esModule, this, request)}
112`;
113 }
114 case "styleTag":
115 case "autoStyleTag":
116 case "singletonStyleTag":
117 default:
118 {
119 const isSingleton = injectType === "singletonStyleTag";
120 const isAuto = injectType === "autoStyleTag";
121 const hmrCode = this.hot ? (0, _utils.getStyleHmrCode)(esModule, this, request, false) : "";
122
123 // eslint-disable-next-line consistent-return
124 return `
125 ${(0, _utils.getImportStyleAPICode)(esModule, this)}
126 ${(0, _utils.getImportStyleDomAPICode)(esModule, this, isSingleton, isAuto)}
127 ${(0, _utils.getImportInsertBySelectorCode)(esModule, this, insertType, options)}
128 ${(0, _utils.getSetAttributesCode)(esModule, this, options)}
129 ${(0, _utils.getImportInsertStyleElementCode)(esModule, this)}
130 ${(0, _utils.getStyleTagTransformFnCode)(esModule, this, options, isSingleton, styleTagTransformType)}
131 ${(0, _utils.getImportStyleContentCode)(esModule, this, request)}
132 ${isAuto ? (0, _utils.getImportIsOldIECode)(esModule, this) : ""}
133 ${esModule ? "" : `content = content.__esModule ? content.default : content;`}
134
135var options = ${JSON.stringify(runtimeOptions)};
136
137${(0, _utils.getStyleTagTransformFn)(options, isSingleton)};
138options.setAttributes = setAttributes;
139${(0, _utils.getInsertOptionCode)(insertType, options)}
140options.domAPI = ${(0, _utils.getdomAPI)(isAuto)};
141options.insertStyleElement = insertStyleElement;
142
143var update = API(content, options);
144
145${hmrCode}
146
147${(0, _utils.getExportStyleCode)(esModule, this, request)}
148`;
149 }
150 }
151};
152var _default = exports.default = loader;
Note: See TracBrowser for help on using the repository browser.