forked from kaleidos/ghost-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
224 lines (213 loc) · 6.18 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
'use strict';
module.exports = function (grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
// Src > input directory
// Dest > output directory
var yeomanConfig = {
app: 'app',
dest: 'dist'
};
grunt.initConfig({
yeoman: yeomanConfig,
//Cleans output directory
clean: {
dist: {
files: [{
dot: true,
src: [
'<%= yeoman.dest %>/*',
'<%= yeoman.dest %>/.git*'
]
}]
}
},
//Copy from input to output static files
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dest %>',
src: [
'*.{ico,txt}',
'.htaccess',
'images/{,*/}*.{webp,gif}'
]
},
//Copy from input to output JS plugins
{
expand: true,
cwd: 'bower_components/',
src: '{,*/}*.js',
dest: '<%= yeoman.dest %>/scripts/libs',
flatten: true,
filter: 'isFile'
}]
}
},
//Minify images and copy to output
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>',
src: ['**/*.{png,jpg,gif}'],
dest: '<%= yeoman.dest %>/images/'
}]
}
},
//Prettify html files and indents al files to 4 spaces
prettify: {
options: {
'indent': 4
},
all: {
expand: true,
cwd: '<%= yeoman.app %>',
ext: '.html',
src: ['*.html'],
dest: '<%= yeoman.dest %>'
}
},
//Minify html and reduce unused data
htmlmin: {
options: {
collapseWhitespace: true,
removeComments: true,
removeEmptyAttributes: true
},
files: {
expand: true,
flatten: true,
src: ['<%= yeoman.dest %>/*.html'],
dest: '<%= yeoman.dest %>'
}
},
//Hints html
htmlhint: {
options: {
'tag-pair': true,
'attr-value-not-empty': true,
'head-script-disabled': true,
'img-alt-require': true
},
src: ['<%= yeoman.app %>/*.html']
},
//Less hints and compile
less: {
development: {
options: {
paths: ['<%= yeoman.dest %>/styles'],
//yuicompress: true, // Enable only when in production
imports: {
less: ['bower_components/lesshat/lesshat.less']
}
},
files: {
'<%= yeoman.dest %>/styles/style.css': '<%= yeoman.app %>/styles/*.less'
}
}
},
//Hints JS files
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'<%= yeoman.app %>/scripts/{,*/}*.js',
'<%= yeoman.app %>/scripts/libs/*'
]
},
//Hints coffeescript files
coffeelint: {
app: ['<%= yeoman.app %>/scripts/*.coffee', '<%= yeoman.app %>/scripts/libs/*.coffee'],
options: {
indentation: { level: 'error', value: 4 }
},
},
//Compile coffeescript files
coffee: {
compile: {
files: {
'<%= yeoman.dest %>/scripts/script.js': ['<%= yeoman.app %>/scripts/*.coffee', '<%= yeoman.app %>/scripts/libs/*.coffee'] // compile and concat into single file
}
},
},
//Uglifys compiled JS
uglify: {
dist: {
files: {
'<%= yeoman.dest %>/scripts/kaleidos.min.js': ['<%= yeoman.dest %>/scripts/script.js']
}
}
},
//Connects the server
connect: {
server: {
options: {
port: 9001,
base: '<%= yeoman.dest %>'
}
}
},
//Watch directories for changes
watch: {
gruntfile: {
files: 'Gruntfile.js',
tasks: ['jshint:all']
},
html: {
files: '<%= yeoman.app %>/*.html',
tasks: ['htmlhint', 'prettify'],
options: {
livereload: true,
}
},
less: {
files: '**/*.less',
tasks: ['less'],
options: {
livereload: true,
}
},
coffee: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
tasks: [
'coffeelint',
'coffee:compile',
'uglify:dist'
]
},
}
});
grunt.loadNpmTasks('assemble-less');
grunt.registerTask('default', [
'jshint',
'coffeelint',
'clean:dist',
'copy:dist',
'imagemin:dynamic',
'htmlhint',
'prettify',
'less',
'connect:server',
'minify'
]);
grunt.registerTask('minify', [
'coffee:compile',
'uglify:dist',
'watch',
]);
grunt.registerTask('development', [
'htmlmin',
'coffee:compile',
'uglify:dist',
'watch',
]);
};