-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
183 lines (147 loc) · 5.51 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
173
174
175
176
177
178
179
180
181
182
183
module.exports = function( grunt ) {
// load time-grunt and all grunt plugins found in the package.json
require( 'time-grunt' )( grunt );
require( 'load-grunt-tasks' )( grunt );
grunt.initConfig({
//variables
site_name: 'presidio-git-io',
//copy files
copy: {
npm: {
files: [
//bootstrap less
{expand: true, cwd: 'node_modules/bootstrap/less/', src: ['**'], dest: '_less/'},
//bootstap js
{expand: true, cwd: 'node_modules/bootstrap/dist/js', src: ['bootstrap.js'], dest: '_js/'},
//bootstap fonts
{expand: true, cwd: 'node_modules/bootstrap/fonts', src: ['**'], dest: 'fonts/'},
//jquery js
{expand: true, cwd: 'node_modules/jquery/dist', src: ['jquery.js'], dest: '_js/'},
//font awesome
{expand: true, cwd: 'node_modules/font-awesome/fonts', src: ['**'], dest: 'fonts/'},
{expand: true, cwd: 'node_modules/font-awesome/css', src: ['font-awesome.css'], dest: '_css/'},
],
},
},
//compile less to css
less : {
all: {
files: {
"_css/bootstrap.css": "_less/bootstrap.less",
"_css/<%= site_name %>.less.css": "_assets/**/*.less",
},
},
},
//validate _css/<%= site_name %>.css and _assets/**.*.css
csslint : {
test : {
options : {
import : 2
},
src : [
'_css/<%= site_name %>.less.css',
'_assets/**/*.css',
],
},
},
//concatenate css files
concat : {
css : {
src : ['_css/bootstrap.css', '_css/font-awesome.css', '_css/<%= site_name %>.less.css', '_assets/**/*.css'],
dest : 'css/<%= site_name %>.css',
},
},
//take all the css files and minify them into <%= site_name %>.min.css
cssmin : {
css : {
src : 'css/<%= site_name %>.css',
dest : 'css/<%= site_name %>.min.css',
},
},
//take all the js files and minify them into <%= site_name %>.min.js
uglify: {
build : {
files: {
//jquery must be before bootstap
'js/<%= site_name %>.min.js': ['_js/jquery.js','_js/bootstrap.js', '_assetts/*.js']
},
},
},
//shell
shell : {
jekyllBuild : {
command : 'bundle exec jekyll build'
},
jekyllServe : {
command : 'bundle exec jekyll serve --watch'
}
},
//content to watch for changes
watch : {
images : {
files : [ 'images/**/*' ],
tasks : [ 'shell:jekyllBuild' ],
options : { debounceDelay: 250 },
},
less : {
files : [ '_assets/**/*.less' ],
tasks : [ 'less', 'concat', 'cssmin', 'shell:jekyllBuild' ],
options : { debounceDelay: 250 },
},
css : {
files : [ '_assets/**/*.css' ],
tasks : [ 'concat', 'cssmin', 'shell:jekyllBuild' ],
options : { debounceDelay: 250 },
},
js : {
files : [ '_assets/**/*.js' ],
tasks : [ 'uglify', 'shell:jekyllBuild' ],
options : { debounceDelay: 250 },
},
jekyll : {
files : [ '_includes/**/*.html', '_layouts/**/*.html', 'index.html', '404.html', '_config.yml' ],
tasks : [ 'shell:jekyllBuild' ],
options : { debounceDelay: 250 },
},
},
// run jekyll server and watch at the same time
concurrent: {
options: {
logConcurrentOutput: true,
},
tasks: [ 'shell:jekyllServe', 'watch' ],
},
clean: {
//remove all dynamic content
//remove generated files from:
//'npm install', 'grunt build', 'bundle exec jekyll build'
generated: [
'fonts',
'js',
'css',
],
//remove non-required staging folders
temp: [
'_js',
'_css',
'_less',
'_site',
'Gemfile.lock',
],
//remove all local npm files (requires 'npm install' to re-gen)
npm: [
'node_modules',
],
}
});
// register custom grunt tasks
//validate pre-minified css files
grunt.registerTask( 'test', [ 'less', 'csslint' ] );
//build dev
grunt.registerTask( 'build', [ 'clean:temp', 'clean:generated', 'copy', 'less', 'concat', 'cssmin', 'uglify', 'clean:temp', 'shell:jekyllBuild' ] );
//start local dev server (http://localhost:4000) and monitor changes to watched folders to kick off recompilation
//default for when grunt is ran with no options
grunt.registerTask( 'default', [ 'concurrent' ] );
//build deploy files and remove dev files for git commit/push
grunt.registerTask( 'deploy', [ 'clean:temp', 'clean:generated', 'copy', 'less', 'concat', 'cssmin', 'uglify', 'clean:temp', 'clean:npm' ] );
};