forked from nicolashery/nicolashery.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
172 lines (155 loc) · 3.61 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
module.exports = function(grunt) {
// Load all NPM grunt tasks
require('matchdep').filterAll('grunt-*').forEach(grunt.loadNpmTasks);
// Project configuration
grunt.initConfig({
meta: {
scripts: [
'js/**/*.js'
],
styles: [
'sass/**/*.scss',
'css/**/*.css'
]
},
// Combine JS modules using Browserify
browserify: {
options: {
// Shim 3rd party libraries not in `node_modules`
shim: {
'jquery': {path: 'bower_components/jquery/jquery.js', exports: 'jQuery'},
'fastclick': {path: 'bower_components/fastclick/lib/fastclick.js', exports: 'jQuery'},
'jquery-jail': {path: 'bower_components/JAIL/src/jail.js', exports: 'jail'}
}
},
debug: {
src: ['app/main.js'],
dest: 'debug/app.js',
options: {
debug: true
}
},
build: {
src: ['app/main.js'],
dest: 'build/app.js'
}
},
// Compile Sass files to CSS
compass: {
options: {
require: 'compass-inuit',
sassDir: 'sass'
},
debug: {
options: {
cssDir: 'debug',
// For source maps
debugInfo: true,
outputStyle: 'expanded'
}
},
build: {
options: {
cssDir: 'build'
}
}
},
// Concatenate files
concat: {
debug: {
files: {
'debug/style.css': ['debug/main.css', 'css/pygments.css']
}
},
build: {
files: {
'build/style.css': ['build/main.css', 'css/pygments.css']
}
}
},
// Minify CSS files
cssmin: {
build: {
files: {
'build/style.min.css': ['build/style.css']
}
}
},
// Minify JS files
uglify: {
build: {
files: {
'build/app.min.js': ['build/app.js']
}
}
},
// Watch files for changes
watch: {
scripts: {
files: ['<%= meta.scripts %>'],
tasks: ['browserify2:debug']
},
styles: {
files: ['<%= meta.styles %>'],
tasks: ['compass:debug', 'concat:debug']
}
},
// Clean target directories
clean: {
debug: ['debug'],
buildTemp: [
'build/main.css',
'build/style.css',
'build/app.js'
],
all: ['debug', 'build']
},
// Run Jekyll commands
jekyll: {
server: {
options: {
serve: true,
// Add the --watch flag, i.e. rebuild on file changes
watch: true
}
},
build: {
options: {
serve: false
}
}
}
});
// Compile JS & CSS, run watch to recompile on change
grunt.registerTask('debug', function() {
// Rebuild './debug'
grunt.task.run([
'clean:debug',
'compass:debug',
'browserify:debug',
'concat:debug'
]);
// Watch for changes
grunt.task.run('watch');
});
// Alias to `grunt jekyll:server`
grunt.registerTask('server', 'jekyll:server');
// Run Jekyll build with environment set to production
grunt.registerTask('jekyll-production', function() {
grunt.log.writeln('Setting environment variable JEKYLL_ENV=production');
process.env.JEKYLL_ENV = 'production';
grunt.task.run('jekyll:build');
});
// Compile and minify JS & CSS, run Jekyll build for production
grunt.registerTask('build', [
'clean:all',
'compass:build',
'browserify:build',
'concat:build',
'cssmin',
'uglify',
'clean:buildTemp',
'jekyll-production'
]);
grunt.registerTask('default', ['debug']);
};