-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gruntfile.js
239 lines (217 loc) · 6.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
'use strict';
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
require('grunt-browserify')(grunt);
// Configurable paths
var paths = {
tmp: '.tmp',
src: './src',
assets: './public'
};
grunt.initConfig({
// Project settings
paths: paths,
config: { version: '1.0.0' },
// Watches files for changes and runs tasks based on the changed files
watch: {
html: {
files: ['./src/_includes/**/*.shtml', './src/views/**/*.html'],
tasks: ['ssi']
},
less: {
files: ['./src/less/**/*.less'],
tasks: ['less', 'usebanner', 'postcss', 'copy']
},
scripts: {
files: ['<%= paths.src %>/js/main.js', '<%= paths.src %>/js/modules/**/*.js'],
tasks: ['jshint', 'concat', 'browserify:dev']
}
},
// Lint LESS
lesslint: {
src: ['.src/less/**/*.less'],
options: {
csslint: {
'box-model': false,
'adjoining-classes': false,
'qualified-headings': false,
'empty-rules': false,
'outline-none': false,
'unique-headings': false
}
}
},
// Lint JS
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'Gruntfile.js',
'<%= paths.assets %>/js/main.js',
'<%= paths.assets %>/js/modules/**/.*.js'
]
},
// LESS -> CSS
less: {
options: {
paths: ['less', 'node_modules'],
compress: true,
sourceMap: true,
sourceMapFileInline: true
},
dist: {
files: [{
expand: true,
cwd: './src/less',
src: ['gisp-theme.less'],
dest: '<%= paths.assets %>/css/',
ext: '.min.css'
}]
}
},
// Add vendor prefixed styles to CSS
postcss: {
options: {
map: false,
processors: [
require('autoprefixer')({ browsers: ['last 4 version'] })
]
},
dist: {
files: [{
expand: true,
cwd: '<%= paths.assets %>/css/',
src: '{,*/}*.css',
dest: '<%= paths.assets %>/css/'
}]
}
},
// Process include files
ssi: {
options: {
cache: 'all',
ext: '.shtml',
baseDir: './src/_includes'
},
dist: {
files: [{
expand: true,
cwd: './src/views/',
src: ['**/*.html'],
dest: './public'
}]
}
},
// Bundle Bootstrap plugins
concat: {
pluginsjs: {
src: [
// 'node_modules/bootstrap/js/affix.js',
// 'node_modules/bootstrap/js/alert.js',
'node_modules/bootstrap/js/dropdown.js',
//'node_modules/bootstrap/js/tooltip.js',
//'node_modules/bootstrap/js/modal.js'
//'node_modules/bootstrap/js/transition.js'
// 'node_modules/bootstrap/js/button.js',
// 'node_modules/bootstrap/js/popover.js',
// 'node_modules/bootstrap/js/carousel.js',
// 'node_modules/bootstrap/js/scrollspy.js',
// 'node_modules/bootstrap/js/collapse.js'
'node_modules/bootstrap/js/tab.js',
],
dest: './public/js/vendor/bootstrap.min.js'
}
},
// Add a banner to the top of the generated LESS file.
usebanner: {
taskName: {
options: {
position: 'top',
banner: '/* FCC GIS Theme v<%= config.version %> | http://fcc.github.io/design-standards/ */\n',
linebreak: true
},
files: {
src: ['<%= paths.assets %>/css/gisp-theme.min.css'],
}
}
},
browserify: {
options: {
browserifyOptions: {
debug: true
}
},
dev: {
src: ['<%= paths.src %>/js/main.js'],
dest: '<%= paths.assets %>/js/app.js'
}
},
uglify: {
options: {
mangle: {
except: ['jQuery', 'Handlebars']
},
sourceMap: false
},
my_target: {
files: {
'<%= paths.assets %>/js/app.min.js': ['<%= paths.assets %>/js/app.js']
}
}
},
'string-replace': {
prod: {
src: '<%= paths.assets %>/**/*.html',
dest: '<%= paths.assets %>/',
options: {
replacements: [{
pattern: 'app.js',
replacement: 'app.min.js'
}]
}
}
},
// Copies remaining files to places other tasks can use
copy: {
dist: {
files: [{ // fonts
dot: true,
expand: true,
cwd: 'node_modules/font-awesome/fonts',
src: '**',
dest: '<%= paths.assets %>/fonts'
}]
}
},
clean: {
release: ['<%= paths.assets %>/js/app.js', '<%= paths.assets %>/css/*.map']
},
});
grunt.registerTask('build:dev', [
'jshint',
'less',
'usebanner',
'postcss',
'ssi',
'concat',
'browserify:dev'
]);
grunt.registerTask('build:release', [
'jshint',
'less',
'usebanner',
'postcss',
'ssi',
'concat',
'browserify:dev',
'uglify',
'string-replace',
'clean'
]);
grunt.registerTask('default', [
'build:dev'
]);
};