-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
148 lines (134 loc) · 3.65 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
module.exports = function ( grunt ) {
/**
* Load required Grunt tasks.
*/
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-recess');
/**
* Load build configuration file.
*/
var userConfig = require( './build.config.js' )( grunt );
/**
* Configure our tasks.
*/
var taskConfig = {
/**
* We read in our `package.json` file so we can access the package name and
* version. It's already there, so we don't repeat ourselves here.
*/
pkg: grunt.file.readJSON("package.json"),
/**
* The banner is the comment that is placed at the top of our compiled
* source files. It is first processed as a Grunt template, where the `<%=`
* pairs are evaluated based on this very configuration object.
*/
meta: {
banner:
'/**\n' +
' * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * <%= pkg.homepage %>\n' +
' *\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed <%= pkg.licenses.type %> <<%= pkg.licenses.url %>>\n' +
' */\n',
// set by shell:commit
commit: ''
},
/**
* The directories to delete when `grunt clean` is executed.
clean: [
'<%= build_dir %>',
'<%= compile_dir %>'
],
*/
/**
* `grunt concat` concatenates multiple source files into a single file.
*/
concat: {
/**
* The `build_css` target concatenates compiled CSS and vendor CSS
* together.
*/
build_css: {
src: [
'<%= vendor_files.css %>',
'<%= recess.build.dest %>'
],
dest: '<%= recess.build.dest %>'
},
},
/**
* Minify the sources!
*/
uglify: {
compile: {
options: {
banner: '<%= meta.banner %>'
},
files: {
'<%= concat.compile_js.dest %>': '<%= concat.compile_js.dest %>'
}
}
},
/**
* `recess` handles our LESS compilation and uglification automatically.
* Only our `main.less` file is included in compilation; all other files
* must be imported from this file.
*/
recess: {
build: {
src: [ '<%= app_files.less %>' ],
dest: '<%= build_dir %>/css/hsd.css',
options: {
compile: true,
compress: false,
noUnderscores: false,
noIDs: false,
zeroUnits: false
}
},
compile: {
src: [ '<%= recess.build.dest %>' ],
dest: '<%= recess.build.dest %>',
options: {
compile: true,
compress: true,
noUnderscores: false,
noIDs: false,
zeroUnits: false
}
}
},
delta: {
options: {
},
/**
* When our JavaScript source files change, we want to run lint them and
* run our unit tests.
jssrc: {
files: [
'<%= app_files.js %>'
],
tasks: [ 'build' ]
},
*/
/**
* When the CSS files change, we need to compile and minify them.
*/
less: {
files: [ 'less/**/*.less' ],
tasks: [ 'recess:build', 'concat:build_css' ]
}
}
};
grunt.initConfig( grunt.util._.extend( taskConfig, userConfig ) );
grunt.renameTask('watch', 'delta');
grunt.registerTask('default', ['watch']);
grunt.registerTask('watch', ['build', 'delta']);
grunt.registerTask('build', [
'recess:build', 'concat:build_css'
]);
};