grunt task to prepend a require.js config to a file
npm install grunt-requirejs-config

shell
npm install grunt-requirejs-config --save-dev
`Then add this line to your project's
Gruntfile.js gruntfile:`javascript
grunt.loadNpmTasks('grunt-requirejs-config');
`Documentation
$3
Here is an example usage which allows you to set your require.js configuration once for your whole Gruntfile:
`js
var requireShim = {
underscore: {
exports: '_'
}
};var requirePaths = {
jquery: 'libs/jquery',
underscore: 'libs/underscore'
};
grunt.initConfig({
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:
`javascript
require(['appController'], function (AppController) {
AppController();
});
`
The output dest file looks like:
`javascript
// Config added by grunt-requirejs-config
require.config({
"shim": {
"underscore": {
"exports": "_"
}
},
"paths": {
"jquery": "libs/jquery",
"underscore": "libs/underscore"
}
});require(['appController'], function (AppController) {
AppController();
});
`
This file starts the app after the config has been set.
Required properties
$3
Type: StringThis is file that require-config uses as your base file to prepend the configuration.
$3
Type: StringThis is the destination of the generated config file.
Options
Any option will be used as a property passed to the require.js config. Here is a page describing all of the options.
Changelog
0.1.0 - Allow full function print in require.js config0.0.2 - Called
done()` on async task0.0.1 - Fixed registered task name
0.0.0 - Initial release