Commit 740d160198fcd9fa6d6d91a2f0324bd2a943c068

Authored by Charles
Committed by GitHub
1 parent aefde45a

fix: keep spaces of env config on prod build (#2015)

Showing 1 changed file with 3 additions and 1 deletions
build/script/buildConf.ts
... ... @@ -21,13 +21,15 @@ function createConfig(params: CreateConfigParams) {
21 21 try {
22 22 const windowConf = `window.${configName}`;
23 23 // Ensure that the variable will not be modified
24   - const configStr = `${windowConf}=${JSON.stringify(config)};
  24 + let configStr = `${windowConf}=${JSON.stringify(config)};`;
  25 + configStr += `
25 26 Object.freeze(${windowConf});
26 27 Object.defineProperty(window, "${configName}", {
27 28 configurable: false,
28 29 writable: false,
29 30 });
30 31 `.replace(/\s/g, '');
  32 +
31 33 fs.mkdirp(getRootPath(OUTPUT_DIR));
32 34 writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr);
33 35  
... ...