diff --git a/package.json b/package.json index 77e18fe..ee6d51c 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "build-visu": "cd ../visualization-component && yarn build:webcomponents", "build": "npm run electron:serve-tsc && ng build --base-href ./", "build:dev": "npm run build -- -c dev", - "build:prod": "npm run build -- -c production && npm run removeMocks", + "build:prod": "node set-env.js && npm run build -- -c production && npm run removeMocks", "web:build": "npm run build -- -c web-production", "electron": "electron", "electron:serve-tsc": "tsc -p tsconfig.serve.json", diff --git a/scripts/set-env.js b/scripts/set-env.js new file mode 100644 index 0000000..146d66d --- /dev/null +++ b/scripts/set-env.js @@ -0,0 +1,12 @@ +const fs = require("fs"); + +const envFilePath = "./src/environments/environment.prod.ts"; +let envFileContent = fs.readFileSync(envFilePath, "utf8"); +const trackerId = process.env.TRACKER_ID; +if (!envFileContent.includes("TRACKER_ID")) { + envFileContent = envFileContent.replace( + /}\s*$/, + ` TRACKER_ID: "${trackerId}",\n}` + ); +} +fs.writeFileSync(envFilePath, envFileContent); diff --git a/src/environments/environment.dev.ts b/src/environments/environment.dev.ts index 4b48ddf..3fe3326 100644 --- a/src/environments/environment.dev.ts +++ b/src/environments/environment.dev.ts @@ -1,5 +1,4 @@ export const APP_CONFIG = { production: false, environment: 'DEV', - TRACKER_ID: process.env.TRACKER_ID, }; diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 8335552..eb2269c 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,5 +1,4 @@ export const APP_CONFIG = { production: true, environment: 'PROD', - TRACKER_ID: process.env.TRACKER_ID, }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index b00b2e0..fd538c5 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,5 +1,4 @@ export const APP_CONFIG = { production: false, environment: 'LOCAL', - TRACKER_ID: process.env.TRACKER_ID, };