Skip to content

Commit bd96f94

Browse files
committed
Updated Grunt tasks for easier development
1 parent c48fb25 commit bd96f94

File tree

3 files changed

+127
-21
lines changed

3 files changed

+127
-21
lines changed

Gruntfile.js

Lines changed: 102 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
/* jshint node: true */
2+
var path = require('path');
3+
var docsFolderMount = function folderMount(connect, point) {
4+
return connect.static(path.resolve(point+'/_gh_pages/'));
5+
};
26

37
module.exports = function(grunt) {
48
"use strict";
59

10+
var modules = {
11+
self: this,
12+
grunt: grunt
13+
};
14+
15+
modules.livereload = require('./assets/js/grunts/livereload')(modules);
16+
617
// Project configuration.
718
grunt.initConfig({
819

@@ -23,16 +34,22 @@ module.exports = function(grunt) {
2334
},
2435

2536
jshint: {
26-
options: {
27-
jshintrc: 'js/.jshintrc'
28-
},
29-
gruntfile: {
30-
src: 'Gruntfile.js'
31-
},
32-
src: {
37+
plugins: {
38+
options: {
39+
jshintrc: 'js/.jshintrc'
40+
},
3341
src: ['js/*.js']
3442
},
43+
assets: {
44+
options: {
45+
jshintrc: 'js/.jshintrc'
46+
},
47+
src: ['assets/js/application.js']
48+
},
3549
test: {
50+
options: {
51+
jshintrc: 'js/.jshintrc'
52+
},
3653
src: ['js/tests/unit/*.js']
3754
}
3855
},
@@ -83,7 +100,7 @@ module.exports = function(grunt) {
83100
options: {
84101
config: 'config.rb',
85102
environment: 'production',
86-
force: grunt.option('force') || false
103+
force: grunt.option('force') || true
87104
}
88105
}
89106
},
@@ -115,11 +132,21 @@ module.exports = function(grunt) {
115132
},
116133

117134
connect: {
118-
server: {
135+
test: {
119136
options: {
120-
port: 9003,
137+
port: 3000,
121138
base: '.'
122139
}
140+
},
141+
// docs server
142+
docs: {
143+
options: {
144+
port: 9001,
145+
hostname: '0.0.0.0',
146+
middleware: function(connect, options) {
147+
return [docsFolderMount(connect, options.base)];
148+
}
149+
}
123150
}
124151
},
125152

@@ -137,17 +164,57 @@ module.exports = function(grunt) {
137164
},
138165

139166
watch: {
140-
src: {
141-
files: '<%= jshint.src.src %>',
142-
tasks: ['jshint:src', 'qunit']
167+
plugins: {
168+
files: '<%= jshint.plugins.src %>',
169+
tasks: ['jshint:plugins', 'qunit'],
170+
options: {
171+
livereload: true
172+
}
173+
},
174+
docsjs: {
175+
files: '<%= jshint.assets.src %>',
176+
tasks: ['jshint:assets'],
177+
options: {
178+
livereload: true
179+
}
143180
},
144181
test: {
145182
files: '<%= jshint.test.src %>',
146-
tasks: ['jshint:test', 'qunit']
183+
tasks: ['jshint:test', 'qunit'],
184+
options: {
185+
livereload: true
186+
}
147187
},
148-
css: {
188+
scss: {
149189
files: ['sass/*.scss', 'sass/*/*.scss'],
150-
tasks: ['compass:bootstrap']
190+
tasks: ['compass:bootstrap'],
191+
options: {
192+
// no need for this because the compile that occurs in compass
193+
// will update the css files that are being watched by the watch:html task
194+
livereload: false
195+
}
196+
},
197+
assets: {
198+
files: ['assets/**/*'],
199+
tasks: ['jekyll:docs'],
200+
options: {
201+
livereload: true
202+
}
203+
},
204+
html: {
205+
files: [
206+
// must watch here to trigger jekyll when compass finishes compiling
207+
'dist/**/*.css',
208+
'fonts/**/*',
209+
'js/**/*',
210+
'**/*.html',
211+
'!_gh_pages/**/*',
212+
'!submodules/**/*'
213+
],
214+
tasks: ['jekyll:docs'],
215+
options: {
216+
livereload: true
217+
}
151218
}
152219
}
153220
});
@@ -167,12 +234,14 @@ module.exports = function(grunt) {
167234
grunt.loadNpmTasks('grunt-html-validation');
168235
grunt.loadNpmTasks('grunt-jekyll');
169236

237+
grunt.registerTask('lr', modules.livereload);
238+
170239
// Docs HTML validation task
171240
grunt.registerTask('validate-html', ['jekyll', 'validation']);
172241

173242
// Test task.
174243
grunt.registerTask('testSubtasks', ['jshint', 'qunit', 'validate-html']);
175-
grunt.registerTask('testSubtasksNoValidation', ['jshint', 'qunit', 'jekyll']);
244+
grunt.registerTask('testSubtasksNoValidation', ['jshint', 'qunit']);
176245
grunt.registerTask('test',
177246
function() {
178247
if(grunt.option('validate')) {
@@ -188,14 +257,29 @@ module.exports = function(grunt) {
188257

189258
// CSS distribution task.
190259
grunt.registerTask('dist-css', ['compass:bootstrap']);
260+
grunt.registerTask('dist-css-min', ['compass:min']);
191261

192262
// Fonts distribution task.
193263
grunt.registerTask('dist-fonts', ['copy:fonts']);
194264

195265
// Full distribution task.
196-
grunt.registerTask('dist', ['clean', 'dist-fonts', 'dist-css', 'dist-js', 'compress:dist']);
266+
grunt.registerTask('dist', ['clean', 'dist-fonts', 'dist-css-min', 'dist-js', 'compress:dist']);
197267

198268
// Default task.
199269
grunt.registerTask('default', ['test', 'dist']);
200270

271+
// Default task that runs jekyll server, delivers uncompressed css and watch capabilities
272+
grunt.registerTask('dev',
273+
[
274+
'lr',
275+
'connect:docs',
276+
'dist-fonts',
277+
'dist-css',
278+
'test',
279+
'dist-js',
280+
'compress:dist',
281+
'watch'
282+
]
283+
);
284+
201285
};

_config.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ pygments: true
66
permalink: pretty
77

88
# Server
9+
source: ./
910
destination: ./_gh_pages
1011
port: 9001
1112

12-
exclude: ["*.zip", "browserstack.json", "node_modules", "twbs", "temp-css", "sass", "less", ".editorconfig", "composer.json", ".ruby-version", ".gitignore", "bower.json", "config.rb", "Gemfile", "Gruntfile.js", "package.json", "Makefile", "Rakefile", "LICENSE", "README.md", "CONTRIBUTING.md", "requirements.txt"]
13+
exclude: ["*.zip", "browserstack.json", "node_modules", "submodules", "temp-css", "sass", "less", ".editorconfig", "composer.json", ".ruby-version", ".gitignore", "bower.json", "config.rb", "Gemfile", "Gruntfile.js", "package.json", "Makefile", "Rakefile", "LICENSE", "README.md", "CONTRIBUTING.md", "requirements.txt"]
1314

1415

1516
## CUSTOM VARS
1617
repo: https://github.com/alademann/sass-bootstrap
17-
download: https://github.com/alademann/sass-bootstrap/zipball/master
18-
download_dist: https://github.com/alademann/sass-bootstrap/blob/master/sass-bootstrap-dist.zip
18+
download: https://github.com/alademann/sass-bootstrap/archive/3.0.16.zip
19+
download_dist: https://github.com/alademann/sass-bootstrap/raw/3.0.16/sass-bootstrap-dist.zip
1920

2021
issues_open: https://github.com/alademann/sass-bootstrap/issues?state=open
2122
issues_new: https://github.com/alademann/sass-bootstrap/issues/new

assets/js/grunts/livereload.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var grunt;
2+
3+
var insertLivereload = function() {
4+
var liveReload = (grunt.option('lr') === true || false);
5+
6+
var livereloadSnippet = "<script>document.write(\'<script src=\"http://\'\n" +
7+
"+ (location.host || \'localhost\').split(\':\')[0]\n" +
8+
"+ \':35729/livereload.js?snipver=1\"><\\/script>\')\n</script>";
9+
10+
var data = "";
11+
12+
if (liveReload) {
13+
data = livereloadSnippet;
14+
}
15+
grunt.file.write("_includes/livereload.html", data);
16+
};
17+
18+
module.exports = function(dependencies) {
19+
grunt = dependencies.grunt
20+
return insertLivereload;
21+
};

0 commit comments

Comments
 (0)