-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
152 lines (138 loc) · 4.03 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
'use strict';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: '/*!\n' +
' * giffgaff styleguide v<%= pkg.version %> by @perpic\n' +
' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' */\n\n',
//Remove folders anf files generated by build task
clean: {
src: [
'src/css',
'src/less/sprites',
'src/images/sprites',
],
build: [
'build',
'dist'
]
},
compress: {
main: {
options: {
archive: 'dist/styleguide.tar.gz',
mode: 'tar'
},
expand: true,
cwd: 'build/',
src: ['**/*'],
dest: 'styleguide/'
}
},
watch: {
less: {
files: ['src/less/*.less'],
tasks: ['recess:css']
}
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'src/js/{,*/}*.js'
]
},
uglify: {
vendor: {
options: {
mangle: false
},
files: {
'build/js/vendor.min.js': [
'src/bower_components/jquery/jquery.js',
'src/bower_components/bootstrap/js/alert.js',
'src/bower_components/bootstrap/js/modal.js',
'src/bower_components/bootstrap/js/tab.js'
]
}
},
giffgaff: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
files: {
'build/js/giffgaff.min.js': [
'src/js/giffgaff.js'
]
}
}
},
recess: {
options: {
compile: true,
banner: '<%= banner %>'
},
css: {
src: ['src/less/giffgaff.less'],
dest: 'src/css/giffgaff.css'
},
min: {
options: {
compress: true
},
src: ['src/less/giffgaff.less'],
dest: 'build/css/giffgaff.min.css'
}
},
glue: {
icons: {
src: 'assets/icons/*',
options: '--css=src/less/sprites --img=src/images/sprites --less --url=../images/sprites/ --namespace=icon --margin=10 --optipng'
}
},
// Copy files not handled in other tasks here
copy: {
src: {
files: [{
expand: true,
cwd: 'src/',
src: [
'images/**'
],
dest: 'build/'
}]
}
},
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-recess');
grunt.loadNpmTasks('grunt-glue');
grunt.loadNpmTasks('grunt-devtools');
// CSS distribution task.
grunt.registerTask('build-css', [
'glue',
'recess'
]);
grunt.registerTask('build', [
'clean',
'build-css',
'uglify',
'copy:src',
'compress'
]);
// Default task(s).
grunt.registerTask('default', [
'jshint',
'build'
]);
};