1
0
mirror of https://github.com/bitwarden/web synced 2025-12-06 00:03:28 +00:00

Compare commits

...

1 Commits

Author SHA1 Message Date
Matt Gibson
e96e3cefd1 Add string replacement feature flagging 2022-01-18 10:56:39 -05:00
6 changed files with 32 additions and 6 deletions

View File

@@ -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;

View File

@@ -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,
};

View File

@@ -7,5 +7,8 @@
"proxyIdentity": "http://localhost:33656",
"proxyEvents": "http://localhost:46273",
"proxyNotifications": "http://localhost:61840"
},
"compileFlags": {
"Test": false
}
}

0
config/empty.ts Normal file
View File

View File

@@ -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(

View File

@@ -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,
}),
];