0.2.1 • Published 9 years ago

grunt-env-config v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

grunt-env-config

npm version Build status

require template and env template helpers for env based grunt config

grunt >= 0.4.0

Installation

npm install grunt-env-config

Enabling Env Config

require('grunt-env-config')(grunt);

Template Usage Guidelines

$require

When expanding the require template string, it'll automatically load the specific module. In order to load the module, you should append dot accessor that reference to valid config object to the $require

// when fetching the value of `a`, it'll load the module './index.js' 
// and the `a` holds the value exported from './index.js' 
grunt.initConfig({
  templateRequire: {
    options: {
      a: '<%= $require.templateRequire.ref %>'
    },
    ref: './index.js'
  }
}

grunt.template.env(prop)

Arguments

  • prop: { String } dot format property accessor
// `a` will hold the value of `process.env.NODE_ENV`
grunt.initConfig({
  templateEnvHelper: {
    options: {
      a: '<%= grunt.template.env("NODE_ENV") %>'
    }
  }
}

grunt.template.through(value)

Arguments

  • value: { Any } it is allowed to pass any pre-defined object, and there is no restriction should only use with env variable.

If value is kind of object, you'll get JSONified value. Otherwise any value should return as what lodash template processed

// `a` will hold the value of `process.env.NODE_ENV`
grunt.initConfig({
  throughTemplateHelper: {
    options: {
      a: '<%= grunt.template.through(process.env.NODE_ENV) %>'
    }
  }
}

License

MIT License