-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGruntfile.js
225 lines (214 loc) · 5.34 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
216
217
218
219
220
221
222
223
224
225
'use strict';
module.exports = function (grunt) {
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Automatically load required Grunt tasks
require('jit-grunt')(grunt, {
useminPrepare: 'grunt-usemin'
});
grunt.loadNpmTasks('grunt-zip');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-protractor-runner');
// Define the configuration for all the tasks
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
karma: {
unit: {
configFile: 'karma.conf.js'
}
},
protractor: {
options: {
configFile: "protractor.conf.js"
},
e2e: {}
},
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: {
src: [
'Gruntfile.js',
'app/script/{,*/}*.js'
]
}
},
copy: {
dist: {
files: [
{
cwd: 'app',
src: '**',
dest: 'dist',
expand: true
},
{
cwd: 'bower_components/angular',
src: 'angular.min.js',
dest: 'dist',
expand: true
},
{
cwd: 'bower_components/angular-route',
src: 'angular-route.min.js',
dest: 'dist',
expand: true
},
{
cwd: 'bower_components/angular-resource',
src: 'angular-resource.min.js',
dest: 'dist',
expand: true
},
{
cwd: 'bower_components/bootstrap/dist/css',
src: 'bootstrap.min.css',
dest: 'dist',
expand: true
},
{
cwd: 'bower_components/bootstrap/js',
src: 'collapse.js',
dest: 'dist/script',
expand: true
},
{
cwd: 'bower_components/jquery/dist',
src: 'jquery.min.js',
dest: 'dist',
expand: true
}
]
},
fonts: {
files:[
{
//for bootstrap fonts
expand: true,
dot: true,
cwd: 'bower_components/bootstrap/dist',
src: ['fonts/*.*'],
dest: 'dist'
}, {
//for font-awesome
expand: true,
dot: true,
cwd: 'bower_components/font-awesome',
src: ['fonts/*.*'],
dest: 'dist'
}
]
}
},
clean: {
build:{
src: [ 'dist/']
}
},
useminPrepare: {
html: 'app/**/*.html',
options: {
dest: 'dist'
}
},
// Concat
concat: {
// dist configuration is provided by useminPrepare
dist: {}
},
// Filerev
filerev: {
options: {
encoding: 'utf8',
algorithm: 'md5',
length: 20
},
release: {
// filerev:release hashes(md5) all assets (images, js and css )
// in dist directory
files: [{
src: [
'dist/script/*.js',
'dist/style/*.css',
]
}]
}
},
// Usemin
// Replaces all assets with their revved version in html and css files.
// options.assetDirs contains the directories for finding the assets
// according to their relative paths
usemin: {
html: ['dist/*.html'],
css: ['dist/style/*.css'],
options: {
assetsDirs: ['dist', 'dist/style']
}
},
watch: {
copy: {
files: [ 'app/**', '!app/**/*.css', '!app/**/*.js'],
tasks: [ 'build' ]
},
scripts: {
files: ['app/script/app.js'],
tasks:[ 'build']
},
styles: {
files: ['app/style/style.css'],
tasks:['build']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'app/{,*/}*.html',
'.tmp/styles/{,*/}*.css',
'app/image/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
livereload: 35729
},
dist: {
options: {
open: true,
base:{
path: 'dist',
options: {
index: 'index.html',
maxAge: 300000
}
}
}
}
},
zip: {
'<%= pkg.name %>-distribution.zip': ['dist/**/*.*']
}
});
grunt.registerTask('build', [
'clean',
'jshint',
'useminPrepare',
'concat',
'uglify',
'cssmin',
'copy',
'filerev',
'usemin'
]);
grunt.registerTask('serve',['build','connect:dist','watch']);
grunt.registerTask('default',['build']);
grunt.registerTask('distribution',['build','zip']);
grunt.registerTask('test', ['karma', 'build', 'connect:dist', 'protractor:e2e']);
};