-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
102 lines (87 loc) · 2.44 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
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
module.exports = function(grunt) {
// load grunt tasks
require('load-grunt-tasks')(grunt);
// configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
options: {
nospawn: true
},
livereload: {
options: {
livereload: LIVERELOAD_PORT
},
files: [
'app/favicon.ico',
'app/**/*.html',
'app/css/{,*/}*.css',
'app/js/**/*.js',
'app/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
connect: {
options: {
port: 9000,
// change this to 'localhost' to prevent access to the server from outside
hostname: '0.0.0.0'
},
livereload: {
options: {
middleware: function (connect) {
return [
mountFolder(connect, 'app'),
lrSnippet
];
}
}
}
},
open: {
server: {
path: 'http://localhost:<%= connect.options.port %>'
}
},
// testing with karma
karma: {
options: {
configFile: 'karma.conf.js',
autoWatch: true
},
single: {
singleRun: true
},
continuous: {
singleRun: false
}
},
// protractor
protractor: {
continuous: {
keepAlive: true, // If false, the grunt process stops when the test fails.
noColor: false, // If true, protractor will not use colors in its output.
configFile: "protractor.conf.js" // Target-specific config file
}
}
});
grunt.registerTask('server', function () {
grunt.task.run([
'connect:livereload',
'open',
'watch'
]);
});
// test
grunt.registerTask('test', function (target) {
if (target !== 'continuous') {
return grunt.task.run(['karma:single', 'connect:livereload', 'protractor:continuous']);
}
grunt.task.run(['karma:continuous']);
});
};