Simple configuration for roots, shared throughout the whole project
CoffeeScript JavaScript Makefile
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Roots Config

npm tests dependencies Coverage Status

Simple configuration for roots, shared through your html, css, and javascript.

Note: This project is in early development, and versioning is a little different. Read this for more details.


  • make sure you are in your roots project directory

  • npm install roots-config --save

  • modify your file to include the extension, as such

    roots_config = require('roots-config')
    module.exports =
      extensions: [roots_config()]


Roots config is a very basic convenience extension. Often times you will want to store all your project's configuration values in one place, and have them available both to your html as locals and to your javascript. To use roots-config, just add it to the extensions as shown above, and pass it an object containing your config values. These values will automatically be available in your views under the config key, and if you use the config_js helper, will also be available globally for your javascript to pick up.

For example, you could have this in your file:

extensions: [roots_config(env: 'development')]

Now, in one of your main view templates, you could have this:

p The current environment is #{config.env}!
!= config_js()

So here, you can see that anything we passed to the extension is available on config. Now, the config_js helper just outputs a script tag that attaches all the config variables to window.config as well, so your js can pick them up. With the helper in place, you could do this in your main.js file:


...and it would return all your config variables. It's that simple!

License & Contributing