UNPKG

zephyr-xpack-internal

Version:

Xpack internals for Zephyr

70 lines (69 loc) • 2.95 kB
"use strict"; var __webpack_require__ = {}; (()=>{ __webpack_require__.d = (exports1, getters, values)=>{ var define = (defs, kind)=>{ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, { enumerable: true, [kind]: defs[key] }); }; define(getters, "get"); define(values, "value"); }; })(); (()=>{ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); })(); (()=>{ __webpack_require__.r = (exports1)=>{ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, { value: 'Module' }); Object.defineProperty(exports1, '__esModule', { value: true }); }; })(); var __webpack_exports__ = {}; __webpack_require__.r(__webpack_exports__); function extractBaseHrefFromPluginOptions(options) { return options?.baseHref; } function extractBaseHrefFromHtmlPlugin(plugins) { const htmlPlugin = plugins.find((plugin)=>plugin?.constructor?.name === 'HtmlWebpackPlugin' || plugin?.constructor?.name === 'HtmlRspackPlugin'); if (!htmlPlugin || !htmlPlugin.options) return; const { base } = htmlPlugin.options; if ('string' == typeof base) return base; if ('object' == typeof base && base?.href) return base.href; } function extractBaseHrefFromPublicPath(compiler) { const publicPath = compiler.options.output?.publicPath; if ('auto' === publicPath || void 0 === publicPath) return; if ('string' == typeof publicPath) return publicPath; if ('function' == typeof publicPath) return void console.warn('Warning: publicPath is a function, cannot extract baseHref automatically.'); } function detectAndStoreBaseHref(zephyr_engine, compiler, pluginOptions) { const baseHref = detectBaseHref(compiler, pluginOptions); if (void 0 !== baseHref) zephyr_engine.buildProperties.baseHref = baseHref; } function detectBaseHref(compiler, pluginOptions) { let baseHref = extractBaseHrefFromPluginOptions(pluginOptions); if (!baseHref && compiler.options?.plugins) baseHref = extractBaseHrefFromHtmlPlugin(compiler.options.plugins); if (!baseHref) baseHref = extractBaseHrefFromPublicPath(compiler); return baseHref; } __webpack_require__.d(__webpack_exports__, { detectAndStoreBaseHref: ()=>detectAndStoreBaseHref, detectBaseHref: ()=>detectBaseHref }); exports.detectAndStoreBaseHref = __webpack_exports__.detectAndStoreBaseHref; exports.detectBaseHref = __webpack_exports__.detectBaseHref; for(var __rspack_i in __webpack_exports__)if (-1 === [ "detectAndStoreBaseHref", "detectBaseHref" ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i]; Object.defineProperty(exports, '__esModule', { value: true }); //# sourceMappingURL=basehref-integration.js.map