grunt task to prepend a require.js config to a file

npm install grunt-requirejs-config
2 downloads in the last day
9 downloads in the last week
31 downloads in the last month


NPM version Dependency Status Build Status

Write your require.js config once in your Gruntfile and prepend it to files for development

Getting Started

If you haven't used grunt before, be sure to check out the Getting Started guide, as it explains how to create a gruntfile as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:

npm install grunt-requirejs-config --save-dev

Then add this line to your project's Gruntfile.js gruntfile:




Here is an example usage which allows you to set your require.js configuration once for your whole Gruntfile:

var requireShim = { 
  underscore: { 
    exports: '_'

var requirePaths = { 
  jquery: 'libs/jquery',
  underscore: 'libs/underscore'

  requirejsconfig: {
    dev: {
      src: 'src/scripts/main.js',
      dest: 'dev/scripts/main.js',
      options: {
        shim: requireShim,
        paths: requirePaths

This is what a sample src file would look like:

require(['appController'], function (AppController) {

The output dest file looks like:

// Config added by grunt-requirejs-config
  "shim": {
    "underscore": {
      "exports": "_"
  "paths": {
    "jquery": "libs/jquery",
    "underscore": "libs/underscore"

require(['appController'], function (AppController) {

This file starts the app after the config has been set.

Required fields


Type: string

This is file that require-config uses as your base file to prepend the configuration.


Type: string

This is the destination of the generated config file.


Any option will be used as a property passed to the require.js config. Here is a page describing all of the options.


0.0.0 - Initial release

0.0.1 - Fixed registered task name

0.0.2 - Called done() on async task

npm loves you