The following guide will describe the steps needed to take a project generated using v2 of the generator and enable it for use with v3.0.
The new v3.0 generator has moved some files, made small changes how script tags and @import statements are injected, and offers users the ability to create a completely custom directory structure. To convert a v2 project to v3.0, do the following:
- Rename and move
js/setup.js
toapp.js
. Modify the related script tag inindex.html
. - Move
css/app.less
toapp.less
. Modify the related link tag inindex.html
. - In
app.less
, modify the existing @import statements and remove the../
from the beginning of the @import statements for all partial and directive less files. - In
app.less
, combine the two comment-separated sections for partial and directive less into one section. Modify the bottom comment marker of this section to be/* Add Component LESS Above */
. - In
index.html
, combine the 4 comment-separated sections for component script tags (for partials, directives, services, filters) into one section. Modify the bottom comment marker of this section to be<!-- Add New Component JS Above -->
. - Overwrite your existing
Gruntfile.js
with the content from Gruntfile.js. Do a find and replace and search for<%%=
and replace with<%=
. - Upgrade the
grunt-dom-munger
task by doingnpm install [email protected] --save-dev
. - Create a
.yo-rc.json
file in the project root with the following content:
{
"generator-rb-angular": {
"uirouter": false,
"partialDirectory": "partial/",
"directiveDirectory": "directive/",
"serviceDirectory": "service/",
"filterDirectory": "filter/",
"inject": {
"js": {
"file": "index.html",
"marker": "<!-- Add New Component JS Above -->",
"template": "<script src=\"<%= filename %>\"></script>"
},
"less": {
"file": "app.less",
"marker": "/* Add Component LESS Above */",
"template": "@import \"<%= filename %>\";"
}
}
}
}
- Modify your
.yo-rc.json
file to look like the following. The only changes are in theless
section. They are the newrelativeToModule
property and the updatedfile
value.
{
"generator-rb-angular": {
"uirouter": false,
"partialDirectory": "partial/",
"directiveDirectory": "directive/",
"serviceDirectory": "service/",
"filterDirectory": "filter/",
"inject": {
"js": {
"file": "index.html",
"marker": "<!-- Add New Component JS Above -->",
"template": "<script src=\"<%= filename %>\"></script>"
},
"less": {
"relativeToModule": true,
"file": "<%= module %>.less",
"marker": "/* Add Component LESS Above */",
"template": "@import \"<%= filename %>\";"
}
}
}
}
- Modify your
app.js
file. The v3.1 generator does not generate the chained calls to$routeProvider
. Please update theapp.js
so that the contents of theconfig
method call look something like:
/* Add New Routes Above */
$routeProvider.otherwise({redirectTo:'/home'});
Notice that there is now no beginning "$routeProvider." above the comment marker. The new generator will inject full statements w/o chaining. For example:
$routeProvider.when('route',{templateUrl:'partial.html'});
$routeProvider.when('route2',{templateUrl:'partial2.html'});
$routeProvider.when('route3',{templateUrl:'partial3.html'});
/* Add New Routes Above */
$routeProvider.otherwise({redirectTo:'/home'});