This Grunt plugin helps make a target app.js for angularjs when you using requirejs with it.
full inspiration from grunt-targethtml, and share both similar usage.
specially when you want to use angular-requirejs base project, and looking for a good way both handling html templates(using grunt-html2js) and distribute with requirejs automatically
This plugin requires Grunt ~0.4.3
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-targetngmodules --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-targetngmodules');
In your project's Gruntfile, add a section named targetngmodules
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
targetngmodules: {
options: {
// Task-specific options go here. Not support any Option yet :(
},
your_target: {
// Target-specific file lists and/or options go here.
'src/scripts/app.js': 'build/scripts/app.js'
},
},
});
//in src/scripts/app.js
define([
'angular',
/*(if target dist)
'templates/views',
*/
'directives',
'controllers',
], function (angular) {
return angular.module('mxphone', [
'ngRoute',
'services',
/*(if target dist)
'crazyApp.crazyModules',
*/
]);
});
//in build/scripts/app.js will look like this
define([
'angular',
'templates/views',
'directives',
'controllers',
], function (angular) {
return angular.module('mxphone', [
'ngRoute',
'services',
'crazyApp.crazyModules',
]);
});
Not Supported yet
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.
(Nothing yet)