Skip to content

Commit

Permalink
chore: reduce logic code
Browse files Browse the repository at this point in the history
  • Loading branch information
Wxh16144 committed Dec 25, 2024
1 parent 5c77d3d commit c93a112
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions packages/bundler-webpack/src/plugins/RuntimePublicPathPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,9 @@ export class RuntimePublicPathPlugin {
)
return;
// @ts-ignore
module._cachedGeneratedCode = `__webpack_require__.p = (function(){
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
function __check(it) {
return it && it.Math === Math && it;
};
var __global =(
__check(typeof globalThis == 'object' && globalThis) ||
__check(typeof window == 'object' && window) ||
__check(typeof self == 'object' && self)
);
if(__global && __global.publicPath) return __global.publicPath;
// fix: https://github.com/umijs/umi/issues/12781
return ${JSON.stringify(compilation.outputOptions.publicPath || '/')};
})();`;
module._cachedGeneratedCode = `__webpack_require__.p = (typeof globalThis !== 'undefined' ? globalThis : window).publicPath || ${
compilation.outputOptions.publicPath ?? '/'
};`;
}
},
);
Expand Down

0 comments on commit c93a112

Please sign in to comment.