Skip to content

Commit

Permalink
fix(build): add webapp upstream features and better coffee
Browse files Browse the repository at this point in the history
Merge changes from generator-webapp and better support for coffee/js
tasks

BREAKING CHANGES: Coffee support in the Gruntfile is only added when the
coffee flag is set. Otherwise, JS is used
Fixes: #35, #440
  • Loading branch information
eddiemonge committed Nov 19, 2013
1 parent ae49dd7 commit c23aceb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
1 change: 1 addition & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ Generator.prototype.createIndexHtml = function createIndexHtml() {
};

Generator.prototype.packageFiles = function () {
this.coffee = this.env.options.coffee;
this.template('../../templates/common/_bower.json', 'bower.json');
this.template('../../templates/common/_package.json', 'package.json');
this.template('../../templates/common/Gruntfile.js', 'Gruntfile.js');
Expand Down
54 changes: 34 additions & 20 deletions templates/common/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ module.exports = function (grunt) {
},

// Watches files for changes and runs tasks based on the changed files
watch: {
watch: {<% if (coffee) { %>
coffee: {
files: ['<%%= yeoman.app %>/scripts/{,*/}*.coffee'],
files: ['<%%= yeoman.app %>/scripts/{,*/}*.{coffee,litcoffee,coffee.md}'],
tasks: ['newer:coffee:dist']
},
coffeeTest: {
files: ['test/spec/{,*/}*.{coffee,js}'],
files: ['test/spec/{,*/}*.{coffee,litcoffee,coffee.md}'],
tasks: ['newer:coffee:test', 'karma']
},<% if (compassBootstrap) { %>
},<% } else { %>
jsTest: {
files: ['test/spec/{,*/}*.js'],
tasks: ['karma']
},<% } %><% if (compassBootstrap) { %>
compass: {
files: ['<%%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
tasks: ['compass:server', 'autoprefixer']
Expand All @@ -52,9 +56,9 @@ module.exports = function (grunt) {
},
files: [
'<%%= yeoman.app %>/{,*/}*.html',
'.tmp/styles/{,*/}*.css',
'.tmp/styles/{,*/}*.css',<% if (!coffee) { %>
'{.tmp,<%%= yeoman.app %>}/scripts/{,*/}*.js',
'<%%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
<% } %>'<%%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
Expand Down Expand Up @@ -100,8 +104,9 @@ module.exports = function (grunt) {
reporter: require('jshint-stylish')
},
all: [
'Gruntfile.js',
'<%%= yeoman.app %>/scripts/{,*/}*.js'
'Gruntfile.js'<% if (!coffee) { %>,
'<%%= yeoman.app %>/scripts/{,*/}*.js',
'test/spec/{,*/}*.js'<% } %>
]
},

Expand All @@ -122,7 +127,9 @@ module.exports = function (grunt) {

// Add vendor prefixed styles
autoprefixer: {
options: ['last 1 version'],
options: {
browsers: ['last 1 version']
},
dist: {
files: [{
expand: true,
Expand All @@ -133,6 +140,7 @@ module.exports = function (grunt) {
}
},

<% if (coffee) { %>
// Compiles CoffeeScript to JavaScript
coffee: {
options: {
Expand All @@ -157,8 +165,9 @@ module.exports = function (grunt) {
ext: '.js'
}]
}
},<% if (compassBootstrap) { %>
},<% } %>

<% if (compassBootstrap) { %>
// Compiles Sass to CSS and generates necessary files if requested
compass: {
options: {
Expand All @@ -167,14 +176,19 @@ module.exports = function (grunt) {
generatedImagesDir: '.tmp/images/generated',
imagesDir: '<%%= yeoman.app %>/images',
javascriptsDir: '<%%= yeoman.app %>/scripts',
fontsDir: '<%%= yeoman.app %>/fonts',
fontsDir: '<%%= yeoman.app %>/styles/fonts',
importPath: '<%%= yeoman.app %>/bower_components',
httpImagesPath: '/images',
httpGeneratedImagesPath: '/images/generated',
httpFontsPath: '/fonts',
relativeAssets: false
httpFontsPath: '/styles/fonts',
relativeAssets: false,
assetCacheBuster: false
},
dist: {
options: {
generatedImagesDir: '<%%= yeoman.dist %>/images/generated'
}
},
dist: {},
server: {
options: {
debugInfo: true
Expand Down Expand Up @@ -311,18 +325,18 @@ module.exports = function (grunt) {

// Run some tasks in parallel to speed up the build process
concurrent: {
server: [
'coffee:dist',<% if (compassBootstrap) { %>
server: [<% if (coffee) { %>
'coffee:dist',<% } %><% if (compassBootstrap) { %>
'compass:server',<% } %>
'copy:styles'
],
test: [
'coffee',<% if (compassBootstrap) { %>
test: [<% if (coffee) { %>
'coffee',<% } %><% if (compassBootstrap) { %>
'compass',<% } %>
'copy:styles'
],
dist: [
'coffee',<% if (compassBootstrap) { %>
dist: [<% if (coffee) { %>
'coffee',<% } %><% if (compassBootstrap) { %>
'compass:dist',<% } %>
'copy:styles',
'imagemin',
Expand Down

0 comments on commit c23aceb

Please sign in to comment.