diff --git a/.gitignore b/.gitignore index 8588024ef..0464abdea 100644 --- a/.gitignore +++ b/.gitignore @@ -77,4 +77,4 @@ cypress/plugins/token.json # Packages ignore package-lock to depend only on yarn package-lock.json -src/assets/runtime-environment.js +scripts/environment.runtime.js diff --git a/angular.json b/angular.json index 02fa219a5..2c392f402 100644 --- a/angular.json +++ b/angular.json @@ -133,7 +133,10 @@ "src/styles.scss", "src/assets/scss/grid.scss" ], - "scripts": ["src/assets/runtime-environment.js"] + "scripts": [ + "/scripts/environment.runtime.js", + "/scripts/onetrust.runtime.js" + ] }, "configurations": { "local": { @@ -370,7 +373,10 @@ "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", "src/styles.scss" ], - "scripts": ["src/assets/runtime-environment.js"], + "scripts": [ + "/scripts/environment.runtime.js", + "/scripts/onetrust.runtime.js" + ], "assets": ["src/favicon.ico", "src/assets", "src/manifest.json"], "sourceMap": true } diff --git a/package.json b/package.json index 1d1695ddd..94c431662 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "start:xx": "ng serve --configuration=local-qa-xx --disable-host-check", "test": "npm run build-runtime-env && ng test", "test-headless": "npm run build-runtime-env && ng test --watch=false --browsers=ChromeHeadless", - "build-runtime-env": "ts-node -P scripts/tsconfig.json scripts/runtime-environment-setter.dev-runtime.ts", + "build-runtime-env": "ts-node -P scripts/tsconfig.json scripts/environment.prebuild.ts", "lint": "echo 'temporally disable Angular linter to until eslint update'", "e2e": "ng e2e", "prebuild": "rimraf dist && yarn build:i18n && yarn build:browserslist && npm run build-runtime-env", diff --git a/scripts/build-info.postbuild.ts b/scripts/build-info.postbuild.ts index 71196530e..e3525f672 100644 --- a/scripts/build-info.postbuild.ts +++ b/scripts/build-info.postbuild.ts @@ -7,8 +7,7 @@ export function buildInfo(indexHtml, options): string { } catch (err) {} const config = ` - ${ gitInfo ? '' : '' diff --git a/scripts/runtime-environment-setter.dev-runtime.ts b/scripts/environment.prebuild.ts similarity index 92% rename from scripts/runtime-environment-setter.dev-runtime.ts rename to scripts/environment.prebuild.ts index 1695f810e..017d625a3 100644 --- a/scripts/runtime-environment-setter.dev-runtime.ts +++ b/scripts/environment.prebuild.ts @@ -10,7 +10,7 @@ ${runtimeEnvironmentScript()}` const outputPath = path.resolve( __dirname, - '../src/assets/runtime-environment.js' + '../scripts/environment.runtime.js' ) fs.writeFileSync(outputPath, scriptContent, { encoding: 'utf8' }) diff --git a/scripts/new-relic.postbuild.ts b/scripts/new-relic.postbuild.ts deleted file mode 100644 index 8231be286..000000000 --- a/scripts/new-relic.postbuild.ts +++ /dev/null @@ -1,64 +0,0 @@ -export function newRelic(indexHtml: string, options) { - if ( - options.environmentVariables && - options.environmentVariables.NEW_RELIC_APP - ) { - return indexHtml.replace( - '', - ` ` - ) - } else { - console.warn( - 'This build will not have google analytics since the UID is not defined on the environment variables' - ) - return indexHtml - } -} diff --git a/scripts/onetrust.postbuild.ts b/scripts/onetrust.postbuild.ts new file mode 100644 index 000000000..cbf0843ae --- /dev/null +++ b/scripts/onetrust.postbuild.ts @@ -0,0 +1,12 @@ +export function addOneTrustNotAutoBlockForAppScripts(data) { + // This regex does the following: + // - `]*\bdata-ot-ignore\b)` is a negative lookahead ensuring that the attribute isn't already present. + // - `([^>]*)` captures any other attributes inside the tag (until the closing '>'). + // + // The replacement inserts "data-ot-ignore" into the tag. + return data.replace( + /]*\bdata-ot-ignore\b)([^>]*)>/gi, + ' - -