Skip to content
RequireJs (r.js) plugin for grunt.js https://github.com/asciidisco/grunt-requirejs
JavaScript CSS
Find file
Latest commit 06fb18a @asciidisco Merge pull request #99 from schorfES/fix-almondify-path
Fix almond path when '.js' appears more than once in path
Failed to load latest commit information.
docs remove custombuilders
examples remove www-build because it is named www-built
lib Fix almond path when '.js' appears more than once in path
tasks remove custombuilders
test
.editorconfig Further refactorings (this time including tests)
.gitattributes
.gitignore ignore logs and test on node 0.10 for travis
.jshintrc
.npmignore Version bump
.travis.yml ignore logs and test on node 0.10 for travis
AUTHORS.md Added a backwards compat. fix; restructured the README
CHANGELOG Version bump
CONTRIBUTING.md Added some more tests
Gruntfile.js cleanup gruntfile and deps
LICENSE-MIT Added basic grunt plugin structure
README.md Fix typo & add a link to grunt-closure-compiler
package.json Version bump

README.md

grunt-requirejs Build Status

Optimize require.js based projects

Getting Started

If you haven't used grunt before, be sure to check out the Getting Started guide.

From the same directory as your project's Gruntfile and package.json, install this plugin with the following command:

npm install grunt-requirejs

Once that's done, add this line to your project's Gruntfile:

grunt.loadNpmTasks('grunt-requirejs');

Overview

Inside your Gruntfile.js file add a section named requirejs. This section specifies the options passed to RequireJS Optimizer.

Parameters

options object

This controls how this task (and its helpers) operate and should contain key:value pairs, see options below.

Options

For a full list of possible options, see the r.js example build file.

Config Example

Example require js optimizer config entry:

  requirejs: {
    compile: {
      options: {
        baseUrl: "path/to/base",
        mainConfigFile: "path/to/config.js",
        out: "path/to/optimized.js"
      }
    }
  }

There is no difference between declaring your require config in your Gruntfile and using a separate requirejs config file.

Note: Minification via Closure Compiler is not supported! You can, however, use grunt-closure-compiler as a separate build step after grunt-requirejs.

Almond

grunt-requirejs is capable of replacing require.js with almond.js automatically

For more infos please take a look at the Almond Integration document

Using custom r.js versions

grunt-requirejs lets you specify a custom r.js for your build

For more infos please take a look at the Using Custom r.js versions document

Using source maps

grunt-requirejs can generate sourcemaps when using the r.js v2.1.2 or higher

For more infos please take a look at the Using Source Maps document

Examples

There are some project & configuration examples to get you started:

Release History

Check the Changleog for more information

Contributing

If you like to file an issue or submit a pull request, please check the contributing guidelines

Contributors

Check the AUTHORS File for more information

Resources

License

Copyright (c) 2012 Sebastian Golasch Licensed under the MIT license.

Something went wrong with that request. Please try again.