Skip to content

Commit 5fb7e5f

Browse files
committed
fix: make webpack plugin compatible with electron
1 parent c6e8c2a commit 5fb7e5f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app-config-webpack/src/loader.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ const loader = function AppConfigLoader(this: Loader) {
4444
4545
const globalNamespace = (typeof window === 'undefined' ? globalThis : window) || {};
4646
47-
// if the global was already defined, use it (and define it if not)
48-
const config = globalNamespace.${privateName} =
49-
(globalNamespace.${privateName} || configValue);
47+
// if the global was already defined, use it
48+
const config = (globalNamespace.${privateName} || configValue);
49+
50+
// if the global is frozen then it was set by electron and we can't change it, but we'll set it if we can
51+
if (!Object.isFrozen(globalNamespace.${privateName})) {
52+
globalNamespace.${privateName} = config;
53+
}
54+
5055
5156
export { config };
5257
export default config;

0 commit comments

Comments
 (0)