Monday, 19 March, 2018 UTC


Summary

  • What if we want to change these at dynamically at build time, lets say we have Chef building our app to a variety of different environments and it needs to flip some things on and off in its config.
  • Next, we need to setup some basic config files, so create a folder called config in the root of your project and lets add a few config files: – default.json – { – features: { – zoo: true, – farm: true – } – } This is a bit verbose…
  • prod.json – { – features: { – zoo: false, – farm: true – } – }Integrating the configWe’ve got these awesome config files but how do we actually get these inside the app so that we can read them out at runtime?
  • Lets create a simple script that will read out the config and write a config file to our environments folder for us: – I put files that are custom scripts in a folder called ~/tools/build .
  • We can automate steps in our build to read out those configs and write files and then have directives read out those objects really easily for a nice feature toggling feature!
When building large scale applications that deploy to a variety of environments with different audiences, we often need the ability to show/hide certain features in the UI. The Angular CLI provides…
@mike_kaufmann: How to use #FeatureFlags – or #FeatureToggles – with #Angular and the Angular CLI – via @amcdnl #DevOps
Feature Toggling with Angular and the Angular CLIWhen building large scale applications that deploy to a variety of environments with different audiences, we often need the ability to show/hide certain features in the UI. The Angular CLI provides us an environment.ts file that can help us quite a bit with this but limited to static values. What if we want to change these at dynamically at build time, lets say we have Chef building our app to a variety of different environments and it needs to flip some things on and off in its config. Dealing with a static environment typescript file is gonna be kind a pain. There is a very popular node package called config (original right?) that lets us do some really tricky stuff like config inheritance, supports a variety of different formats and allows us to set variables at runtime. This article could just focus on that topic alone but I wanted to get a bit more specific with it in terms of feature toggling. So how would we do this?
Setting up configFirst lets install config from npm like:
npm i config –DWe are only using this at build time, so make sure to install as a dev dependency. Next, we need to setup some basic config files, so create a folder called config in the root of your project and lets add a few config files:
default.json
{
features: {
zoo: true,
Feature Toggling with Angular and the Angular CLI – Austin – Medium