Skip to content

Commit c23aceb

Browse files
committed
fix(build): add webapp upstream features and better coffee
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
1 parent ae49dd7 commit c23aceb

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

Diff for: app/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ Generator.prototype.createIndexHtml = function createIndexHtml() {
281281
};
282282

283283
Generator.prototype.packageFiles = function () {
284+
this.coffee = this.env.options.coffee;
284285
this.template('../../templates/common/_bower.json', 'bower.json');
285286
this.template('../../templates/common/_package.json', 'package.json');
286287
this.template('../../templates/common/Gruntfile.js', 'Gruntfile.js');

Diff for: templates/common/Gruntfile.js

+34-20
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@ module.exports = function (grunt) {
2626
},
2727

2828
// Watches files for changes and runs tasks based on the changed files
29-
watch: {
29+
watch: {<% if (coffee) { %>
3030
coffee: {
31-
files: ['<%%= yeoman.app %>/scripts/{,*/}*.coffee'],
31+
files: ['<%%= yeoman.app %>/scripts/{,*/}*.{coffee,litcoffee,coffee.md}'],
3232
tasks: ['newer:coffee:dist']
3333
},
3434
coffeeTest: {
35-
files: ['test/spec/{,*/}*.{coffee,js}'],
35+
files: ['test/spec/{,*/}*.{coffee,litcoffee,coffee.md}'],
3636
tasks: ['newer:coffee:test', 'karma']
37-
},<% if (compassBootstrap) { %>
37+
},<% } else { %>
38+
jsTest: {
39+
files: ['test/spec/{,*/}*.js'],
40+
tasks: ['karma']
41+
},<% } %><% if (compassBootstrap) { %>
3842
compass: {
3943
files: ['<%%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
4044
tasks: ['compass:server', 'autoprefixer']
@@ -52,9 +56,9 @@ module.exports = function (grunt) {
5256
},
5357
files: [
5458
'<%%= yeoman.app %>/{,*/}*.html',
55-
'.tmp/styles/{,*/}*.css',
59+
'.tmp/styles/{,*/}*.css',<% if (!coffee) { %>
5660
'{.tmp,<%%= yeoman.app %>}/scripts/{,*/}*.js',
57-
'<%%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
61+
<% } %>'<%%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
5862
]
5963
}
6064
},
@@ -100,8 +104,9 @@ module.exports = function (grunt) {
100104
reporter: require('jshint-stylish')
101105
},
102106
all: [
103-
'Gruntfile.js',
104-
'<%%= yeoman.app %>/scripts/{,*/}*.js'
107+
'Gruntfile.js'<% if (!coffee) { %>,
108+
'<%%= yeoman.app %>/scripts/{,*/}*.js',
109+
'test/spec/{,*/}*.js'<% } %>
105110
]
106111
},
107112

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

123128
// Add vendor prefixed styles
124129
autoprefixer: {
125-
options: ['last 1 version'],
130+
options: {
131+
browsers: ['last 1 version']
132+
},
126133
dist: {
127134
files: [{
128135
expand: true,
@@ -133,6 +140,7 @@ module.exports = function (grunt) {
133140
}
134141
},
135142

143+
<% if (coffee) { %>
136144
// Compiles CoffeeScript to JavaScript
137145
coffee: {
138146
options: {
@@ -157,8 +165,9 @@ module.exports = function (grunt) {
157165
ext: '.js'
158166
}]
159167
}
160-
},<% if (compassBootstrap) { %>
168+
},<% } %>
161169

170+
<% if (compassBootstrap) { %>
162171
// Compiles Sass to CSS and generates necessary files if requested
163172
compass: {
164173
options: {
@@ -167,14 +176,19 @@ module.exports = function (grunt) {
167176
generatedImagesDir: '.tmp/images/generated',
168177
imagesDir: '<%%= yeoman.app %>/images',
169178
javascriptsDir: '<%%= yeoman.app %>/scripts',
170-
fontsDir: '<%%= yeoman.app %>/fonts',
179+
fontsDir: '<%%= yeoman.app %>/styles/fonts',
171180
importPath: '<%%= yeoman.app %>/bower_components',
172181
httpImagesPath: '/images',
173182
httpGeneratedImagesPath: '/images/generated',
174-
httpFontsPath: '/fonts',
175-
relativeAssets: false
183+
httpFontsPath: '/styles/fonts',
184+
relativeAssets: false,
185+
assetCacheBuster: false
186+
},
187+
dist: {
188+
options: {
189+
generatedImagesDir: '<%%= yeoman.dist %>/images/generated'
190+
}
176191
},
177-
dist: {},
178192
server: {
179193
options: {
180194
debugInfo: true
@@ -311,18 +325,18 @@ module.exports = function (grunt) {
311325

312326
// Run some tasks in parallel to speed up the build process
313327
concurrent: {
314-
server: [
315-
'coffee:dist',<% if (compassBootstrap) { %>
328+
server: [<% if (coffee) { %>
329+
'coffee:dist',<% } %><% if (compassBootstrap) { %>
316330
'compass:server',<% } %>
317331
'copy:styles'
318332
],
319-
test: [
320-
'coffee',<% if (compassBootstrap) { %>
333+
test: [<% if (coffee) { %>
334+
'coffee',<% } %><% if (compassBootstrap) { %>
321335
'compass',<% } %>
322336
'copy:styles'
323337
],
324-
dist: [
325-
'coffee',<% if (compassBootstrap) { %>
338+
dist: [<% if (coffee) { %>
339+
'coffee',<% } %><% if (compassBootstrap) { %>
326340
'compass:dist',<% } %>
327341
'copy:styles',
328342
'imagemin',

0 commit comments

Comments
 (0)