-
Notifications
You must be signed in to change notification settings - Fork 1
/
gruntfile.js
145 lines (136 loc) · 4.56 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
module.exports = function(grunt) {
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
grunt.initConfig({
pkg: grunt.file.readJSON('bower.json'),
dir: {
publish: 'public',
theme: 'client/theme',
build: 'client/.build',
vendor: {
bower: 'bower_components'
}
},
// Javascript processing
// minify to build then uglify to publish
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> */\n'
},
libs: {
files: {
'<%= dir.publish %>/js/libs.min.js': [
'<%= dir.vendor.bower %>/jquery/dist/jquery.min.js',
'<%= dir.vendor.bower %>/bootstrap-sass-official/assets/javascripts/bootstrap.js',
'<%= dir.vendor.bower %>/lodash/dist/lodash.min.js'
]
}
},
},
// stylesheet processing
// compile sass to build,
sass: {
dist: {
files: {
'<%= dir.build %>/stylesheets/<%= pkg.name %>.css': '<%= dir.theme %>/stylesheets/<%= pkg.name %>.scss',
}
}
},
// css minify to publish
cssmin: {
publish: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> */',
keepSpecialComments: 0
},
files: {
'<%= dir.publish %>/<%= pkg.name %>.min.css': ['<%= dir.build %>/stylesheets/<%= pkg.name %>.css']
}
}
},
// copy images and fonts that don't need processing
copy: {
libs: {
files: [{
expand: true,
flatten: true,
src: ['<%= dir.vendor.bower %>/**/{*.png,*.jpg,*.gif}'],
dest: '<%= dir.publish %>/img',
filter: 'isFile'
}, {
expand: true,
flatten: true,
src: ['<%= dir.vendor.bower %>/**/{*.eot,*.svg,*.ttf,*.woff,*.otf}'],
dest: '<%= dir.publish %>/fonts',
filter: 'isFile'
}]
},
theme: {
files: [{
expand: true,
flatten: true,
src: ['<%= dir.theme %>/images/**'],
dest: '<%= dir.publish %>/img',
filter: 'isFile'
}, {
expand: true,
flatten: true,
src: ['<%= dir.theme %>/fonts/**'],
dest: '<%= dir.publish %>/fonts',
filter: 'isFile'
}]
}
},
// always clean up the build and publish dirs
clean: {
build: ['<%= dir.build %>/'],
publish: [
'<%= dir.publish %>/<%= pkg.name %>.min.css',
'<%= dir.publish %>/js',
'<%= dir.publish %>/fonts',
'<%= dir.publish %>/img',
]
},
// keeping 'em on the straight and narrow
jshint: {
files: ['gruntfile.js', '<%= dir.theme %>/javascript/**/*.js'],
options: {
// options here to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true,
document: true
}
}
},
watch: {
css: {
files: ['<%= dir.theme %>/stylesheets/**/*'],
tasks: ['sass', 'cssmin'],
},
assets: {
files: ['<%= dir.theme %>/images/**/*', '<%= dir.theme %>/fonts/**/*'],
tasks: ['copy'],
},
scripts: {
files: ['<%= dir.theme %>/javascript/*'],
tasks: ['uglify:theme'],
},
},
nodemon: {
dev: {
script: './bin/www'
}
},
concurrent: {
dev: {
tasks: ['nodemon', 'watch'],
options: {
logConcurrentOutput: true
}
}
},
});
grunt.registerTask('default', ['jshint', 'clean', 'sass', 'cssmin', 'uglify', 'copy']);
grunt.registerTask('develop', ['default', 'concurrent:dev']);
};