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,13 +21,15 @@ function createConfig(params: CreateConfigParams) {
21 try { 21 try {
22 const windowConf = `window.${configName}`; 22 const windowConf = `window.${configName}`;
23 // Ensure that the variable will not be modified 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 Object.freeze(${windowConf}); 26 Object.freeze(${windowConf});
26 Object.defineProperty(window, "${configName}", { 27 Object.defineProperty(window, "${configName}", {
27 configurable: false, 28 configurable: false,
28 writable: false, 29 writable: false,
29 }); 30 });
30 `.replace(/\s/g, ''); 31 `.replace(/\s/g, '');
  32 +
31 fs.mkdirp(getRootPath(OUTPUT_DIR)); 33 fs.mkdirp(getRootPath(OUTPUT_DIR));
32 writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr); 34 writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr);
33 35