Find RequireJS modules and make a file which contains corresponding paths config.
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-requirejspaths --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-requirejspaths');
In your project's Gruntfile, add a section named requirejspaths
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
requirejspaths: {
options: {
// Task-specific options go here.
}
},
});
This task depends on grunt.filerev.summary
object. So filerev
task of grunt-filerev plugin must be run first.
Type: String
Default value: ''
Base path of RequireJS module script files.
Type: String
Default value: ''
Use as the value of baseUrl
property of configuration object for require.config()
.
Type: Array
Default value: undefined
The names of RequireJS modules.
Type: String
Default value: undefined
Path of the output file, e.g. ".tmp/requirejspaths.html"
.
Type: String
Default value:
<script>
"use strict";
require.config({
<% if (baseUrl) { %> baseUrl: "<%= baseUrl %>",
<% } %>
paths: <%= JSON.stringify(moduleMappings, null, 2) %>
});
</script>
A template string for rendering the output file. If options.templateFile
is specified, this option is ignored.
Type: String
Default value: undefined
A template file whose content is used for rending the output file. This option overrides options.template
.
Type: Boolean
Default value: true
If you want to output a pure JavaScript file, set this to false
.
Type: Boolean
Default value: true
Output the 'use strict'
detective before the JavaScript code.
Type: Boolean
Default value: false
If true
, skip the file not found in grunt.filerev.summary
. Otherwise it will show a warning (the default behavior).
(New in v0.2.3)
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.
v0.2.1 Fix docs.
v0.2.0 Add scriptTag
and useStrict
options.
v0.1.0 Initial release.