source: trip-planner-front/node_modules/style-loader/dist/index.js@ 84d0fbb

Last change on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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