Reputation: 241
We are using Keycloak
with keycloak-js
to secure our Webapps in Production. So it is deeply integrated into our Frontends.
To start development, we always need to start a keycloak container.
Is there any good way to bypass keycloak-js and get rid of the keycloak container during dev?
The current approach is a feature toggle on NODE_ENV
.
What do you think about that?
Upvotes: 0
Views: 856
Reputation: 241
For now, i found a quite good solution using the webpack.DefinePlugin
.
I define a MYAPP_PRODUCTION
variable and replace it via Webpack in the build process.
If MYAPP_PRODUCTION
is false override my keycloak object/export and mock the required functions.
Webpack config:
more infos: https://webpack.js.org/plugins/define-plugin/
new webpack.DefinePlugin({
MYAPP_PRODUCTION: JSON.stringify(true),
...
}
Inside the app bootstrapping
// sourcecode
if(!MYAPP_PRODUCTION) {
// mock keycloak here
}
the compiled output in production mode will not include the statements inside the if-clause. webpack will automatically omit the conditional stuff because if (!true) { ... }
will never be true.
Upvotes: 1