gulp-ng-config

  • Provide any string you want, just make sure to include <%= module %> for where you want to embed the angular module.
  • We now can include this configuration module in our main app and access the constants
  • By default, json file is used to generate the module.
  • The Gulp plugin will allow you to provide an object of properties and will generate an Angular module of constants.
  • We will pipe this through gulpNgConfig and out will come an angular module of constants.

AngularJS configuration generator for a module of constants

@atticoos: v1.4.0 release
🌟 Include multiple environments/keys
🌟 Support for custom template files
#gulp #angularjs #changelog

It’s often useful to generate a file of constants, usually as environment variables, for your Angular apps. This Gulp plugin will allow you to provide an object of properties and will generate an Angular module of constants.

and out will come an angular module of constants.

contains:

with the following content:

We now can include this configuration module in our main app and access the constants

Currently there are a few configurable options to control the output of your configuration file:

Optional

If your configuration contains multiple environments, you can supply the key you want the plugin to load from your configuration file.

file with multiple environments:

Usage of the plugin:

Expected output:

If the configuration is nested it can be accessed by the namespace, for example

Usage of the plugin:

Expected output:

Multiple environment keys can be supplied in an array, for example for global and environmental constants

Usage of the plugin:

Expected output:

Optional

You can also override properties from your json file or add more by including them in the gulp tasks:

Optional

can be overridden. Possible types:

service.

Optional

to false.

with an existing angular module

Optional

Presets:

Wrap the configuration module in an IIFE or your own wrapper.

Will produce an IIFE wrapper for your configuration module:

for where you want to embed the angular module.

The reuslting file will contain:

Default value: ‘json’ Optional

file,

Generating,

formatted output string.

object in the constants, instead of inline.

This allows the developer to provide a custom output template.

Configuration:

Gulp task:

Sample output:

. Now config values can come from environment variables, command-line arguments or anywhere else.

as a configuration to the plugin

, and if you are introducing or changing a feature, that you add/update any tests involved.

gulp-ng-config