Skip to content

Latest commit

 

History

History
83 lines (69 loc) · 2.13 KB

File metadata and controls

83 lines (69 loc) · 2.13 KB

grunt-requirejs-config-generator

concatenating config specified into json files into final requirejs config file

Getting Started

This plugin requires Grunt ~0.4.4

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, you may install this plugin with this command:

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

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-requirejs-config-generator');

The "requirejs_config_generator" task

Overview

In your project's Gruntfile, add a section named requirejs_config_generator to the data object passed into grunt.initConfig().

grunt.initConfig({
  requirejs_config_generator: {
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});

Usage Examples

Default Options

In this example, the default options are used to do something with whatever. So if the testing file has the content

{
 "baseUrl": "",
 "deps": [],
 "paths": {},
 "shim": {}
}

and the 123 file had the content

{
  "deps": ["deps0"],
  "paths": {
    "util": "util",
    "common": "common"
  },
  "shim": {
    "jquery": {
      "exports": "jQuery"
    }
  }
}

, the generated result would be

requirejs.config({"baseUrl":"","deps":["deps0"],"paths":{"util":"util","common":"common"},"shim":{"jquery":{"exports":"jQuery"}}});
grunt.initConfig({
  requirejs_config_generator: {
    files: {
      'dest/default_options': ['src/testing', 'src/123'],
    },
  },
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

0.1.2 Multiple destination files 0.1.1 fixed dependencies 0.1.0 base functionality