Grunt task to convert a Backbone project to an AngularJS project
See this dir for a demo "Hello, World" app
generated by grunt-bb2ng. Generated JS is in test.js
.
This plugin requires Grunt ~0.4.1
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-bb2ng --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-bb2ng');
In your project's Gruntfile, add a section named bb2ng
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
bb2ng: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
Type: String
Default value: 'myApp'
A string value representing the name of your brand new AngularJS module.
In this example, we create a new AngularJS app named myApp
.
grunt.initConfig({
bb2ng: {
options: {},
files: {
'dest/my-angularjs-app.js': ['path/to/my-backbone-app.js',
'path/to/some-other-file.js'],
},
},
})
Here, we can specify the name of our new AngularJS app:
grunt.initConfig({
bb2ng: {
options: {
name: 'omg-angularjs-roolz'
},
files: {
'dest/my-angularjs-app.js': ['path/to/my-backbone-app.js',
'path/to/some-other-file.js']
},
},
})
You'll need to include the generated file (above, my-angularjs-app.js
) and bootstrap your
AngularJS app in some way. The easiest way to do this is to add an ngApp="myApp"
(or whatever
you named your module) attribte to the <body>
or <html>
tag of your HTML, as seen here.
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.
0.1.1
Documentation updates0.1.0
Initial Release
😆