Gathering detailed insights and metrics for grunt-requirejs-generator
Gathering detailed insights and metrics for grunt-requirejs-generator
Gathering detailed insights and metrics for grunt-requirejs-generator
Gathering detailed insights and metrics for grunt-requirejs-generator
grunt-requirejs-config-generator
concatenating into final requirejs config file
grunt-bower-requirejs-config-generator
A generator of require config file with paths and shims, getting informations from bower.json
grunt-spec
Grunt plugin which provides a spec/object generator and a simple mechanism for using requirejs as a DI container to provide jasmine spies to module specs
generator-angular-requirejs-grunt-bower
Integrate AngularJs, Requirejs, Grunt and Bower with your project.
npm install grunt-requirejs-generator
Typescript
Module System
Min. Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
4
Grunt requirejs config generator
This plugin requires Grunt ~0.4.2
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:
1npm install grunt-requirejs-config --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
1grunt.loadNpmTasks('grunt-requirejs-config');
2grunt.loadNpmTasks('grunt-contrib-yuidoc');
The plugin depends on YUIDoc, therefor you need to load that as well
/**
*
* @author Martijn van Beek <martijn@blueberry.nl>
* @since 16 June 2014
* @namespace nl.blueberry
* @class ClassNameExtended
* @extends ClassName
* @uses jQuery
*/
These comments are indexed with yuidoc and are used to determine the dependencies.
In your project's Gruntfile, add a section named requirejs-config
to the data object passed into grunt.initConfig()
.
1grunt.initConfig({ 2 'requirejs_generator':{ 3 config: { 4 options: { 5 yuidoc_dir: 'build/apidocs', 6 build_dir: 'build', 7 debug: true, 8 config: grunt.file.readJSON("config/requirejs/paths.json"), 9 output: 'html/assets/js/source/<%= pkg.main %>.js', 10 main: '<%= pkg.main %>', 11 application: '<%= pkg.requirejs_generator.application %>', 12 uml: true, 13 replace:{ 14 that:'html/assets/', 15 with:'/app-assets/media-manager/' 16 }, 17 ignore: '<%= pkg.requirejs_generator.ignore %>', 18 jshint: '<%= pkg.requirejs_generator.jshint %>', 19 minify:{ 20 enabled:true, 21 config: grunt.file.readJSON("config/requirejs/paths-minify.json"), 22 outDir: 'html/assets/js/min', 23 output: '<%= pkg.main %>.js', 24 app: 'App-<%= pkg.main %>.js' 25 } 26 } 27 } 28 }, 29});
Your config could be inside your package.json:
1{ 2 "name": "<name>", 3 "description": "<description>", 4 "version": "<version>", 5 "main": "<name-of-js-file-to-create>", 6 "homepage": "<your-homepage>", 7 "devDependencies": { 8 "grunt": "~0.4.2", 9 "grunt-contrib-uglify": "~0.6.0", 10 "grunt-contrib-yuidoc": "~0.5.0", 11 "grunt-requirejs-generator": "~0.0.5" 12 }, 13 "yuidoc":{ 14 "options": { 15 "outdir": "build/apidocs", 16 "paths": [ 17 "html/assets/js/source/" 18 ] 19 } 20 }, 21 "requirejs_generator":{ 22 "application":"<start-class>", 23 "ignore":[ 24 "IgnoreClass" 25 ], 26 "jshint":[ 27 'Handlebars' 28 ] 29 } 30}
The task generates a file that is not runnable, you need to create a Loader file, for example:
Your source version can differ from the minified version, this is a puzzle that cannot be resolved via the task (I'm still searching for a solution for this).
1require(["MediaManagerRequire"], function(){ 2 require(["Export"], function(){ 3 require(["MediaManagerLoader"]); 4 }); 5});
1require(["MediaManagerRequire"], function(){ 2 require(["Application"], function() { 3 require(["jQuery"], function() { 4 require(["App"], function() { 5 require(["MediaManagerLoader"]); 6 }); 7 }); 8 }); 9});
1{ 2 "paths": { 3 "jQuery" : "//code.jquery.com/jquery-2.1.1.js" , 4 "Class" : "html/assets/bower/classy/classy.js" , 5 "raphael" : "html/assets/bower/raphael/raphael.js" , 6 "Bootstrap" : "html/assets/bower/bootstrap-sass/dist/js/bootstrap.js", 7 "Handlebars" : "/app-assets/editor/bower/handlebars/handlebars.js" 8 }, 9 "shim" : { 10 "jQuery":{}, 11 "Class":{}, 12 "raphael": { 13 "deps": [ 14 "jQuery" 15 ] 16 }, 17 "Handlebars": { 18 "deps": [ 19 "jQuery" 20 ] 21 } 22 }, 23 "external":[ 24 "raphael" 25 ] 26}
The above setup will load jQuery from it's CDN in both versions, this is because the path is starting with a slash. Handlebars is therefor also loaded from the given location.
Do you have a AMD module that doesn't play nice you can define it in the "external" array and it will be copied to your directory that is defined in options.minify.outDir and loaded before the rest ( note: with it's dependencies, does need also be loaded external! )
Type: String
Default value: build
The location where all the files are stored for yuidoc and requirejs-config
Type: String
Default value: build/apidocs
The location where the apidocs are generated
Type: Boolean
Default value: false
Show more output
Type: String
Default value: ``
The file where requirejs-config will write it's result
Type: String
Default value: ``
The file name
Type: Boolean
Default value: false
Create a file that can be read by umljs (copy resources/uml.html to your build dir and view it)
Type: Object
Transform resolved paths by yuidoc to a format that is suitable for your project
Type: String
Default value: ``
A string to replace in the resolved paths
Type: String
Default value: ``
A string to put in place
Type: Array
Default value: []
Class names that Yuidoc has found that you want to ignore (if everything is configured correctly this is not necessary)
Type: Array
Default value: []
Enable jshint updating with resolved files and add this list
Type: Object
Default value: {}
Settings for minifing your code
Type: Boolean
Default value: false
Is minifing enabled?
Type: Object
Default value: {}
Override the require js with minified paths
Type: String
Default value: ``
Directory to write the files
Type: String
Default value: ``
The filename to write the require js setup for the minified version
Type: String
Default value: ``
The filename to write the minified code
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.
No vulnerabilities found.
No security vulnerabilities found.