-
Notifications
You must be signed in to change notification settings - Fork 463
/
Gruntfile.js
171 lines (161 loc) · 3.54 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
// Generated on 2013-11-30 using generator-angular-component 0.2.3
'use strict';
module.exports = function(grunt) {
// Configurable paths
var yoConfig = {
livereload: 35729,
src: 'src',
dist: 'dist'
};
// Livereload setup
var lrSnippet = require('connect-livereload')({port: yoConfig.livereload});
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
require('load-grunt-tasks')(grunt);
// 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']
},
app: {
files: [
'{.tmp,<%= yo.src %>}/{,*/}*.js'
],
options: {
livereload: yoConfig.livereload
}
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'qunit']
}
},
connect: {
options: {
port: 9000,
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)
];
}
}
}
},
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
}
},
copy: {
dist: {
expand: true,
cwd: '<%= yo.src %>',
src: '**',
dest: '<%= yo.dist %>'
}
},
usebanner: {
dist: {
options: {
position: 'top',
banner: '<%= meta.banner %>'
},
files: {
src: [ '<%= yo.dist %>/*.js' ]
}
}
},
uglify: {
options: {
banner: '<%= meta.banner %>'
},
dist: {
files: {
'<%= copy.dist.dest %>/<%= pkg.name %>.min.js': '<%= copy.dist.dest %>/<%= pkg.name %>.js',
}
}
}
});
grunt.registerTask('test', [
'jshint',
'karma:unit'
]);
grunt.registerTask('build', [
'clean:dist',
'copy:dist',
'usebanner:dist',
'uglify:dist'
]);
grunt.registerTask('release', [
'test',
'bump-only',
'build',
'bump-commit'
]);
grunt.registerTask('default', ['build']);
};