From 740d160198fcd9fa6d6d91a2f0324bd2a943c068 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 5 Jul 2022 11:42:49 +0800 Subject: [PATCH] fix: keep spaces of env config on prod build (#2015) --- build/script/buildConf.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/script/buildConf.ts b/build/script/buildConf.ts index aa7b84399..0c8089cc1 100644 --- a/build/script/buildConf.ts +++ b/build/script/buildConf.ts @@ -21,13 +21,15 @@ function createConfig(params: CreateConfigParams) { try { const windowConf = `window.${configName}`; // Ensure that the variable will not be modified - const configStr = `${windowConf}=${JSON.stringify(config)}; + let configStr = `${windowConf}=${JSON.stringify(config)};`; + configStr += ` Object.freeze(${windowConf}); Object.defineProperty(window, "${configName}", { configurable: false, writable: false, }); `.replace(/\s/g, ''); + fs.mkdirp(getRootPath(OUTPUT_DIR)); writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr);