zephyr-modernjs-plugin
Version:
Modernjs plugin for Zephyr
88 lines (87 loc) • 3.22 kB
JavaScript
;
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__);
__webpack_require__.d(__webpack_exports__, {
shouldApplyDevPublicPathFix: ()=>shouldApplyDevPublicPathFix,
withZephyr: ()=>with_zephyr_withZephyr
});
const external_zephyr_agent_namespaceObject = require("zephyr-agent");
const pluginName = 'zephyr-modernjs-plugin';
const isDev = 'development' === process.env['NODE_ENV'];
function shouldApplyDevPublicPathFix(target, development = isDev) {
return development && 'tap-app' !== target;
}
const with_zephyr_withZephyr = (zephyrOptions)=>{
if (zephyrOptions?.target !== void 0) (0, external_zephyr_agent_namespaceObject.assertZephyrBuildTarget)(zephyrOptions.target, 'withZephyr({ target })');
return {
name: pluginName,
pre: [
'@modern-js/plugin-module-federation-config'
],
async setup (api) {
api['modifyRspackConfig'](async (config)=>{
const { withZephyr } = await import("zephyr-rspack-plugin");
const configureZephyr = withZephyr(zephyrOptions);
return await configureZephyr(config);
});
},
usePlugins: shouldApplyDevPublicPathFix(zephyrOptions?.target) ? [
zephyrFixPublicPath(zephyrOptions?.target)
] : []
};
};
function zephyrFixPublicPath(target) {
return {
name: 'zephyr-publicpath-fix',
pre: [
pluginName
],
setup (api) {
api['modifyRspackConfig'](async (config, { isServer })=>{
if (!isServer && 'tap-app' !== target) {
external_zephyr_agent_namespaceObject.ze_log.misc('Modifying publicPath for Dev Server');
config.output = {
...config.output,
publicPath: 'auto'
};
}
});
}
};
}
exports.shouldApplyDevPublicPathFix = __webpack_exports__.shouldApplyDevPublicPathFix;
exports.withZephyr = __webpack_exports__.withZephyr;
for(var __rspack_i in __webpack_exports__)if (-1 === [
"shouldApplyDevPublicPathFix",
"withZephyr"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
value: true
});
//# sourceMappingURL=with-zephyr.js.map