-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
184 lines (179 loc) · 5.45 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
184
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-jekyll');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint'); // Local dev only
grunt.loadNpmTasks('grunt-jsbeautifier'); // Ditto
grunt.loadNpmTasks('grunt-browser-sync'); // Ditto. Requires node.
grunt.loadNpmTasks('grunt-open');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Watch task
watch: {
options: {
spawn: false
},
// Lint, beautify, copy assets and reload on JS file edits
js: {
files: ['ui/js/*.js', 'Gruntfile.js'],
tasks: ['jshint', 'jsbeautifier', 'copy:js'],
options: {
livereload: true
}
},
// Less compile, copy assets on edit
less: {
files: ['ui/less/*.less'],
tasks: ['less:development', 'copy:css'],
// BrowserSync is now watching for CSS changes
//options: {
//livereload: true
//}
},
images: {
files: ['ui/img/*'],
tasks: ['copy:images'],
options: {
livereload: true
}
},
html: {
// Order matters!
// Watch for changes to files and regenerate _site on edit
files: ['**/*.html', '**/*.md', '**/*.csv', '!**/node_modules/**', '!**/bower_components/**'],
tasks: ['jekyll:dist'],
options: {
livereload: true,
debounceDelay: 300,
}
}
},
// BrowserSync task
// Keep browsers in sync and inject CSS changes (or reload for images)
browserSync: {
dev: {
bsFiles: {
src: [
'_site/assets/*.css',
'_site/ui/img/*.jpg',
'_site/ui/img/*.png'
]
},
options: {
watchTask: true
}
}
},
// Less task
less: {
options: {},
development: {
files: [{
expand: true,
cwd: 'ui/less/',
//src: ['**/*.less'],
src: ['styles.less'],
dest: 'ui/css/',
ext: '.css',
report: 'min'
}]
},
production: {}
},
// Copy task
// Move files on edit so that the livereload works as expected
copy: {
css: {
files:
// includes files within path
[{
expand: true,
src: ['ui/css/*'],
dest: '_site/assets/',
flatten: true,
filter: 'isFile'
}]
},
js: {
files:
// includes files within path
[{
expand: true,
src: ['ui/js/*'],
dest: '_site/assets/',
flatten: true,
filter: 'isFile'
}]
},
images: {
files: [{
expand: true,
src: ['ui/img/*'],
dest: '_site/ui/img/',
filter: 'isFile'
}]
}
},
// JSHint task
jshint: {
options: {
force: true
},
all: ['ui/js/*.js', 'Gruntfile.js', '!**/node_modules/**', '!**/bower_components/**'],
},
jsbeautifier: {
files: ['ui/js/*.js', 'Gruntfile.js', '!**/node_modules/**', '!**/bower_components/**']
},
// Jekyll tasks
jekyll: {
options: {
bundleExec: true // run commands with bundle exec ...
},
dist: { // jekyll build
options: {
config: '_config.yml,_config.development.yml,_config.development_w_grunt.yml',
drafts: true
}
},
serve: { // Not using this, because we're using Connect
options: {
drafts: true,
serve: true
}
}
},
// Connect tasks
connect: {
server: {
options: {
port: 4000,
base: '_site'
}
}
},
// Open the browser!
//open: {
//dev: {
//path: 'http://localhost:4000',
//app: 'Google Chrome',
//delay: 5
//}
//},
});
// Default task(s).
grunt.registerTask('default', ['serve']);
grunt.registerTask('serve', function(target) {
grunt.task.run([
'connect',
'less:development',
'jshint',
'jsbeautifier',
'jekyll:dist',
'browserSync',
//'open:dev',
'watch'
]);
});
};