Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

Commit

Permalink
Add support for Babel
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebuilds committed May 17, 2015
1 parent 862b94e commit de5077b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 6 deletions.
8 changes: 8 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ module.exports = yeoman.generators.Base.extend({
});
this.testFramework = this.options['test-framework'];

this.option('babel', {
desc: 'Use Babel',
type: Boolean,
defaults: true
});
this.babel = this.options.babel;

this.option('coffee', {
desc: 'Use CoffeeScript',
type: Boolean,
Expand Down Expand Up @@ -180,6 +187,7 @@ module.exports = yeoman.generators.Base.extend({
options: {
'skip-message': this.options['skip-install-message'],
'skip-install': this.options['skip-install'],
'babel': this.options.babel,
'coffee': this.options.coffee
}
});
Expand Down
41 changes: 37 additions & 4 deletions app/templates/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ module.exports = function (grunt) {
bower: {
files: ['bower.json'],
tasks: ['wiredep']
},<% if (coffee) { %>
},<% if (babel) { %>
babel: {
files: ['<%%= config.app %>/scripts/{,*/}*.js'],
tasks: ['babel:dist']
},
babelTest: {
files: ['test/spec/{,*/}*.js'],
tasks: ['babel:test', 'test:watch']
},<% } else if (coffee) { %>
coffee: {
files: ['<%%= config.app %>/scripts/{,*/}*.{coffee,litcoffee,coffee.md}'],
tasks: ['coffee:dist']
Expand Down Expand Up @@ -155,6 +163,28 @@ module.exports = function (grunt) {
specs: 'test/spec/{,*/}*.js'
}
}
},<% } %><% if (babel) { %>
// Compiles ES6 with Babel
babel: {
dist: {
files: [{
expand: true,
cwd: '<%%= config.app %>/scripts',
src: '{,*/}*.js',
dest: '.tmp/scripts',
ext: '.js'
}]
},
test: {
files: [{
expand: true,
cwd: 'test/spec',
src: '{,*/}*.js',
dest: '.tmp/spec',
ext: '.js'
}]
}
},<% } %><% if (coffee) { %>

// Compiles CoffeeScript to JavaScript
Expand Down Expand Up @@ -405,16 +435,19 @@ module.exports = function (grunt) {

// Run some tasks in parallel to speed up build process
concurrent: {
server: [<% if (coffee) { %>
server: [<% if (babel) { %>
'babel:dist',<% } %><% if (coffee) { %>
'coffee:dist',<% } %><% if (includeSass) { %>
'sass:server'<% } else { %>
'copy:styles'<% } %>
],
test: [<% if (coffee) { %>
test: [<% if (babel) { %>
'babel',<% } %><% if (coffee) { %>
'coffee'<% } %><% if (coffee && !includeSass) { %>,<% } %><% if (!includeSass) { %>
'copy:styles'<% } %>
],
dist: [<% if (coffee) { %>
dist: [<% if (babel) { %>
'babel',<% } %><% if (coffee) { %>
'coffee',<% } %><% if (includeSass) { %>
'sass',<% } else { %>
'copy:styles',<% } %>
Expand Down
3 changes: 2 additions & 1 deletion app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"grunt-autoprefixer": "^2.2.0",
"grunt-browser-sync": "^2.1.2",
"grunt-concurrent": "^1.0.0",
"grunt-contrib-clean": "^0.6.0",<% if (coffee) { %>
"grunt-contrib-clean": "^0.6.0",<% if (babel) { %>
"grunt-babel": "^5.0.0",<% } %><% if (coffee) { %>
"grunt-contrib-coffee": "^0.13.0",<% } %>
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
Expand Down
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

* CSS Autoprefixing
* Built-in preview server with LiveReload
* Automagically compile CoffeeScript & Sass
* Automagically compile ES6 (with Babel), CoffeeScript & Sass
* Automagically lint your scripts
* Automagically wire up your Bower components with [grunt-wiredep](#third-party-dependencies).
* Awesome Image Optimization (via OptiPNG, pngquant, jpegtran and gifsicle)
Expand Down Expand Up @@ -66,6 +66,10 @@ We have [recipes](docs/recipes) for integrating other popular technologies like

Defaults to `mocha`. Can be switched for another supported testing framework like `jasmine`.

* `--babel`

Add support for [Babel](http://babeljs.io/).

* `--coffee`

Add support for [CoffeeScript](http://coffeescript.org/).
Expand Down

0 comments on commit de5077b

Please sign in to comment.