-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
190 lines (178 loc) · 4.5 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
// Generated on 2013-10-19 using generator-angular-component 0.2.3
'use strict';
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-connect');
// Configurable paths
var yoConfig = {
livereload : 35729,
src : 'src',
dist : 'dist',
test : 'test/spec'
};
// Livereload setup
var lrSnippet = require('connect-livereload')({
port : yoConfig.livereload
});
var mountFolder = function(connect, dir) {
return connect.static(require('path').resolve(dir));
};
// Load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Project configuration
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),
yo : yoConfig,
meta : {
banner : '/**\n' + ' * <%= pkg.name %>\n' + ' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' + ' * @link <%= pkg.homepage %>\n' + ' * @author <%= pkg.author.name %> <<%= pkg.author.email %>>\n' + ' * @license MIT License, http://www.opensource.org/licenses/MIT\n' + ' */\n'
},
open : {
server : {
path : 'http://localhost:<%= connect.options.port %>'
}
},
clean : {
dist : {
files : [{
dot : true,
src : ['.tmp', '<%= yo.dist %>/*', '!<%= yo.dist %>/.git*']
}]
},
server : '.tmp'
},
watch : {
gruntfile : {
files : '<%= jshint.gruntfile.src %>',
tasks : ['jshint:gruntfile']
},
less : {
files : ['<%= yo.src %>/{,*/}*.less'],
tasks : ['less:dist']
},
app : {
files : ['<%= yo.src %>/{,*/}*.html', '{.tmp,<%= yo.src %>}/{,*/}*.css', '{.tmp,<%= yo.src %>}/{,*/}*.js'],
options : {
livereload : yoConfig.livereload
}
},
test : {
files : '<%= jshint.test.src %>',
tasks : ['jshint:test', 'qunit']
}
},
connect : {
options : {
keepalive: true,
port : 9001,
base : 'www',
hostname : '0.0.0.0' // Change this to '0.0.0.0' to access the server from outside.
},
livereload : {
options : {
middleware : function(connect) {
return [lrSnippet, mountFolder(connect, '.tmp'), mountFolder(connect, yoConfig.src)];
}
}
}
},
less : {
options : {
// dumpLineNumbers: 'all',
paths : ['<%= yo.src %>']
},
dist : {
files : {
'<%= yo.src %>/<%= yo.name %>.css' : '<%= yo.src %>/<%= yo.name %>.less'
}
}
},
jshint : {
gruntfile : {
options : {
jshintrc : '.jshintrc'
},
src : 'Gruntfile.js'
},
src : {
options : {
jshintrc : '.jshintrc'
},
src : ['<%= yo.src %>/{,*/}*.js']
},
test : {
options : {
jshintrc : 'test/.jshintrc'
},
src : ['test/**/*.js']
}
},
karma : {
options : {
configFile : 'karma.conf.js',
browsers : ['PhantomJS']
},
unit : {
singleRun : true
},
server : {
autoWatch : true
}
},
ngmin : {
options : {
banner : '<%= meta.banner %>'
},
dist : {
src : ['<%= yo.src %>/<%= pkg.name %>.js'],
dest : '<%= yo.dist %>/<%= pkg.name %>.js'
}
// dist: {
// files: {
// '/.js': '/.js'
// }
// }
},
concat : {
options : {
banner : '<%= meta.banner %>',
stripBanners : true
},
dist : {
src : ['<%= yo.src %>/<%= pkg.name %>.js'],
dest : '<%= yo.dist %>/<%= pkg.name %>.js'
}
},
uglify : {
options : {
banner : '<%= meta.banner %>'
},
dist : {
src : '<%= concat.dist.dest %>',
dest : '<%= yo.dist %>/<%= pkg.name %>.min.js'
}
},
coffee : {
compile : {
files : {
'<%= yo.src %>/<%= pkg.name %>.js' : '<%= yo.src %>/<%= pkg.name %>.coffee',
'<%= yo.test %>/<%= pkg.name %>.js' : '<%= yo.test %>/<%= pkg.name %>.coffee'
}
}
}
});
// After running "npm install connect --save-dev" to add connect as a dev
// dependency of your project, you can require it in your gruntfile with:
var connect = require('connect');
// Now you can define a "connect" task that starts a webserver, using the
// connect lib, with whatever options and configuration you need:
grunt.registerTask('server', 'Start a custom static web server.', function() {
grunt.log.writeln('Starting static web server in "www" on port 9001.');
connect(connect.static('www')).listen(9001);
});
grunt.registerTask('test', ['coffee:compile',
//'jshint',
'karma:unit']);
grunt.registerTask('build', ['clean:dist', 'less:dist', 'ngmin:dist', 'coffee:compile', 'uglify:dist']);
grunt.registerTask('release', ['test', 'bump-only', 'dist', 'bump-commit']);
grunt.registerTask('default', ['test', 'build']);
};