-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
148 lines (143 loc) · 3.98 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({ port: LIVERELOAD_PORT });
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
var previewDir = 'public';
module.exports = function (grunt) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
options: {
hostname: '0.0.0.0',
port: 8000
},
livereload: {
options: {
middleware: function (connect) {
return [
lrSnippet,
mountFolder(connect, previewDir)
];
}
}
}
},
concurrent: {
options: {
logConcurrentOutput: true
},
full: ['watch:staticsass', 'watch:static', 'watch:staticjs', 'watch:full'],
static: ['watch:staticsass', 'watch:static', 'watch:staticjs']
},
copy: {
js: {
files:[{
expand:true,
cwd: 'source/javascripts/',
src:['**/**'],
dest:'public/javascripts/'
}]
}
},
exec: {
generate: {
cmd: 'bundle exec rake generate'
}
},
sass: {
dev: {
files: {
'stylesheets/custom/custom.css': 'stylesheets/custom/custom.scss'
}
},
static: {
files: {
'public/stylesheets/custom/custom.css': 'sass/custom/custom.scss'
}
}
},
// templating (conditional includes)
targethtml: {
public: {
files: [{
expand:true,
src:['public/**/*.html']
}]
}
},
open: {
dev: {
path: 'http://localhost:<%= connect.options.port%>'
}
},
prettify: {
options: {
config:'.prettifyrc'
},
public: {
expand:true,
dest:'public/',
cwd:'public/',
src:['**/*.html']
}
},
uglify: {
public: {
files: [
{'public/javascripts/custom.js': ['public/javascripts/custom.js']},
{'public/javascripts/libs.js': ['public/javascripts/libs/modernizr-2.8.3.js', 'public/javascripts/octopress.js','public/javascripts/libs/github-widgets.js', 'public/javascripts/libs/hn.min.js']}
]
}
},
watch: {
static: {
files: ['public/**'],
options: {
livereload: LIVERELOAD_PORT
}
},
// these all trigger static, so no livereload necessary
staticsass:{
files: ['sass/**'],
tasks: ['sass:static']
},
staticjs: {
files: ['source/javascripts/**'],
tasks: ['copy:js']
},
full: {
files: ['source/**/*{.js,.html,.yml,.md,.markdown,.css,.sass,.scss,.xml}', '**/*{.yml,.rb,.ru}', '!source/javascripts/**','!sass/**','!public/**', '!_deploy/**', '!node_modules/**'],
tasks:['exec:generate'],
}
}
});
grunt.registerTask('port', 'Same as static, but with port as an argument', function (portArg) {
var connect = grunt.config.get('connect');
connect.options.port = portArg || 80;
grunt.config.set('connect', connect);
grunt.task.run('static');
});
// regenerate full, entire project upon changes in source files, except for sass stylesheets and js files, which are selectively rebuilt and copied over without regenerating the entire project
grunt.registerTask('default', [
'exec:generate',
'connect:livereload',
'open',
'concurrent:full',
]);
// only watch public folder, sass stylesheets, and js files (preview mode)
grunt.registerTask('static', [
'exec:generate',
'prettify:public', // re-run same prettify tasks to check for whitespace errors
'connect:livereload',
'open',
'concurrent:static'
]);
// run build tasks after 'rake generate' but before rake deploy. This means operating on files in the public directory.
grunt.registerTask('pre-deploy', [
'targethtml:public',
'prettify:public',
'uglify:public'
]);
};