diff --git a/bitwarden_license/webpack.config.js b/bitwarden_license/webpack.config.js index bae0682f..ec16291c 100644 --- a/bitwarden_license/webpack.config.js +++ b/bitwarden_license/webpack.config.js @@ -3,10 +3,6 @@ const { AngularWebpackPlugin } = require("@ngtools/webpack"); const webpackConfig = require("../webpack.config"); webpackConfig.entry["app/main"] = "./bitwarden_license/src/app/main.ts"; -webpackConfig.plugins[webpackConfig.plugins.length - 1] = new AngularWebpackPlugin({ - tsConfigPath: "tsconfig.json", - entryModule: "bitwarden_license/src/app/app.module#AppModule", - sourceMap: true, -}); +webpackConfig.plugins[webpackConfig.plugins.length - 1].entryModule = "bitwarden_license/src/app/app.module#AppModule"; module.exports = webpackConfig; diff --git a/config.js b/config.js index 2bfc929d..ab173529 100644 --- a/config.js +++ b/config.js @@ -30,7 +30,24 @@ function loadConfig(configName) { } } +function generateSubstitutions(configObj) { + let result = {}; + + Object.keys(configObj.compileFlags ?? {}).forEach(key => { + result = { ...result, ...generateSubstitutionsForFlag(key) }; + }); + + return result; +} + +function generateSubstitutionsForFlag(flagName) { + return { + "featureFlag: (.*)[\\s\\S]*?\\/\\/ endFeatureFlag": "" + }; +} + module.exports = { load, log, + generateSubstitutions, }; diff --git a/config/development.json b/config/development.json index 7554af38..84de944e 100644 --- a/config/development.json +++ b/config/development.json @@ -7,5 +7,8 @@ "proxyIdentity": "http://localhost:33656", "proxyEvents": "http://localhost:46273", "proxyNotifications": "http://localhost:61840" + }, + "compileFlags": { + "Test": false } } diff --git a/config/empty.ts b/config/empty.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index cd9335e7..950242bf 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -37,6 +37,9 @@ import { SyncService } from "jslib-common/abstractions/sync.service"; import { TokenService } from "jslib-common/abstractions/token.service"; import { ModalService } from "jslib-angular/services/modal.service"; +// featureFlag: Test +import { TestService } from 'jslib-common/services/test.service'; +// endFeatureFlag const BroadcasterSubscriptionId = "VaultComponent"; @@ -89,10 +92,12 @@ export class VaultComponent implements OnInit, OnDestroy { private ngZone: NgZone, private stateService: StateService, private organizationService: OrganizationService, - private providerService: ProviderService + private providerService: ProviderService, + /* featureFlag: Test */private testService: TestService, // endFeatureFlag ) {} async ngOnInit() { + /** featureFlag: Test */ this.testService.Print("test service was loaded"); // endFeatureFlag this.showVerifyEmail = !(await this.tokenService.getEmailVerified()); this.showBrowserOutdated = window.navigator.userAgent.indexOf("MSIE") !== -1; this.trashCleanupWarning = this.i18nService.t( diff --git a/webpack.config.js b/webpack.config.js index b67170e3..9d509382 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -17,6 +17,9 @@ const NODE_ENV = process.env.NODE_ENV == null ? "development" : process.env.NODE const envConfig = config.load(ENV); config.log(envConfig); +const fileReplacements = {}; +const substitutions = config.generateSubstitutions(envConfig); + const moduleRules = [ { test: /\.ts$/, @@ -155,6 +158,8 @@ const plugins = [ tsConfigPath: "tsconfig.json", entryModule: "src/app/app.module#AppModule", sourceMap: true, + fileReplacements: fileReplacements, + substitutions: substitutions, }), ];