forked from nohros/nsPopover
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gruntfile.js
215 lines (197 loc) · 5.63 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
module.exports = function(grunt) {
/**
* Load required Grunt tasks. These are installed based on the versions listed
* in `package.json` when you do `npm install` in this directory.
*/
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-conventional-changelog');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-ngmin');
var userConfig = require('./build.config.js');
var taskConfig = {
pkg: grunt.file.readJSON("package.json"),
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'
},
/**
* Creates a CHANGELOG on a new version.
*/
changelog: {
options: {
dest: 'CHANGELOG.md',
template: 'changelog.tpl'
}
},
/**
* Increments the version number, etc.
*/
bump: {
options: {
files: [
"package.json",
"bower.json"
],
commit: false,
commitMessage: 'chore(release): v%VERSION%',
commitFiles: [
"package.json",
"bower.json"
],
createTag: false,
tagName: 'v%VERSION%',
tagMessage: 'Version %VERSION%',
push: false,
pushTo: 'origin'
}
},
/**
* The copy task just copies files from A to B. We use it here to copy
* our project javascripts into 'build_dir'.
*/
copy: {
js: {
files: [{
src: ['<%= app_files.js %>'],
dest: '<%= build_dir %>/',
cwd: '.',
expand: true,
flatten: true
}]
},
example : {
files : [{
src: ['<%= build_dir %>/**/*'],
dest: '<%= example_dir %>/',
cwd: '.',
expand: true,
flatten: true
}]
}
},
/**
* The directories to delete when 'grunt clean' is executed.
*/
clean: [
'<%= compile_dir %>',
'<%= build_dir %>'
],
/**
* 'grunt concat' concatenates multiple source files into a single file.
*/
concat: {
compile: {
options: {
banner: '<%= meta.banner %>'
},
src: [
'<%= app_files.js %>'
],
dest: '<%= compile_dir %>/<%= pkg.name %>.min.js'
}
},
/**
* 'ng-min' annotates the sources before minifying. That is, it allows us to code
* without the array syntax.
*/
ngmin: {
compile: {
files: [{
src: ['<%= concat.compile.dest %>'],
cwd: '<%= compile_dir %>',
dest: '<%= concat.compile.dest %>',
expand: true
}]
}
},
uglify: {
compile: {
options: {
banner: '<%= meta.banner %>'
},
files: {
'<%= concat.compile.dest %>': '<%= concat.compile.dest %>'
}
}
},
/**
* `jshint` defines the rules of our linter as well as which files we
* should check. This file, all javascript sources, and all our unit tests
* are linted based on the policies listed in `options`. But we can also
* specify exclusionary patterns by prefixing them with an exclamation
* point (!); this is useful when code comes from a third party but is
* nonetheless inside `src/`.
*/
jshint: {
src: [
'<%= app_files.js %>'
],
test: [
'<%= app_files.jsunit %>'
],
gruntfile: [
'Gruntfile.js'
],
options: {
curly: true,
immed: true,
newcap: true,
noarg: true,
sub: true,
boss: true,
eqnull: true
},
globals: {}
},
/**
* `sass` handles our sass compilation and uglification automatically.
* Only our `main.sass` file is included in compilation; all other files
* must be imported from this file.
*/
sass: {
build: {
src: [ '<%= app_files.sass %>' ],
dest: '<%= build_dir %>/<%= pkg.name %>.css',
files: {
'<%= sass.build.dest %>' : '<%= sass.build.src %>'
},
options : {
compass: false,
lineNumbers: true
}
},
compile: {
src: [ '<%= app_files.sass %>' ],
dest: '<%= compile_dir %>/<%= pkg.name %>.css',
files: {
'<%= sass.compile.dest %>' : '<%= sass.compile.src %>'
},
options : {
compass: false,
style: 'compressed',
banner: '<%= meta.banner %>'
}
}
}
};
grunt.initConfig(grunt.util._.extend(taskConfig, userConfig));
grunt.registerTask('default', ['build', 'compile']);
grunt.registerTask('build', ['clean', 'sass:build', 'copy:js', 'copy:example']);
grunt.registerTask('js', ['clean', 'jshint', 'copy:js', 'copy:example']);
/**
* The 'compile' task gets your app ready for deployment by concatenating and
* minifying your code.
*/
grunt.registerTask('compile', ['sass:compile', 'concat:compile', 'uglify', 'ngmin']);
};