Zguillez | Guillermo de la Iglesia
Icosa-hk | Icosahedron
Yeoman generator for Backbone.js webapp development. With RequireJS, Bootstrap, Sass, and templating with Pug and Lodash
npm install -g yo
erators
To install generator-base-backbone from npm, run:
npm install -g generator-base-backbone
//or:
sudo npm install -g generator-base-backbone
Finally, initiate the generator:
yo base-backbone
If you have error on install try to update dependences manually:
sudo npm updatebower updateFor update npm
sudo npm install npm -g
npm install -g bower
sudo gem install sass
Documentation:
Develop code on folder /src
/src
/data
/images
/scripts
/collections
/views
/styles
/templates
Use grunt task to compile code and deploy webapp
grunt serve
THis will launch server on port 9000
http://localhost:9000/
Distribute code is compileded on forder /dist
/dist
/css
/data
/images
/js
/lib
/templates
Sass files (*.sass, *.scss) must be located on /src/styles folder root.
- Grunt task sass.js will process the files into CSS files to folder /src/styles/css.
- Grunt task copy.js will copy all CSS files into /src/styles/css to folder /dist/css for ditribution.
- You can also create and edit CSS files in /src/styles/css.
The NodeJS template engine PUG is implemented. Pug files (*.pug) must be located on /templates folder root.
- Grunt task pug.js will process the files into HTML files to folder /templates/html.
- Grunt task copy.js will copy all CSS files into /templates/html to folder /dist/templates for ditribution.
- You can also create and edit HTML templates files in /templates/html.
You can use combined Pug and Lodash for templating:
//templates/index.pug
header#header
section(class='content')
header
img(class='logo', src='images/backbone.png')
.buttons.row
<% _.forEach(libs, function(lib) { %>
<%= '<a href="' + lib.url + '" target="_black" data-bypass="data-bypass" class="btn btn-default btn-sm">' + lib.name + '</a>' %>
<% }); %>
footer#footer
Documentation:
Grunt task copy.js will read all bower.js files from /bower_components subfolders, and copy the file path from main node, like:
//bower_components/requirejs/bower.json
{
...
"main": "require.js",
...
}
And put this files into folder /dist/lib/.
If any installed dependency has no bower.json file (like lodash) you must edit the copy.js task to manually copy it:
grunt.config.set('copy', {
...
lodash_: {
cwd: 'bower_components/lodash/dist',
src: 'lodash.js',
dest: 'dist/lib/',
expand: true
},
...
});
If an unnecesaary file is copied (like boostrap.less):
//bower_components/bootstrap/bower.json
{
...
"main": [
"less/bootstrap.less",
"dist/js/bootstrap.js"
],
...
}
you can delete it with the clean-dist.js task:
//grunt/clean-dist.js
grunt.registerTask('clean-dist', 'Clean dist folder', function() {
...
grunt.config.set('clean.files.src', ['dist/lib/bootstrap.less']);
...
});
Contributors are welcome, please fork and send pull requests! If you have any ideas on how to make this project better then please submit an issue or send me an email.
©2016 Zguillez.io
Original code licensed under MIT Open Source projects used within this project retain their original licenses.
- Removes Bootstrap Native
- Update Jade to Pug
- Update dependencies
- Uses Bootstrap Native
- Uses Jquery 3
- Update dependencies
- Fix Backbone require on collections
- Auto copy dependecies fron bower.json file
- Fix yo install version
Initial Backbone.js skeleton
Features:
- Bootstrap
- Jquery
- Sass
- Lodash
- Jade templating
- JSHint code chech
- Grunt tasks
