Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 2a8b12b

Browse files
committed
chore(grunt): add serve task
Use connect and watch to serve the development
1 parent 4b12eb9 commit 2a8b12b

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

gruntFile.js

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = function(grunt) {
55
require('load-grunt-tasks')(grunt);
66

77
// Default task.
8-
grunt.registerTask('default', ['jshint', 'karma']);
8+
grunt.registerTask('default', ['jshint', 'karma:unit']);
9+
grunt.registerTask('serve', ['karma:continuous', 'dist', 'build:gh-pages', 'connect:continuous', 'watch']);
910
grunt.registerTask('dist', ['ngmin', 'uglify']);
1011

1112

@@ -51,11 +52,20 @@ module.exports = function(grunt) {
5152
''].join('\n')
5253
},
5354

55+
connect: {
56+
options: {
57+
base : 'out/built/gh-pages',
58+
open: true,
59+
livereload: true
60+
},
61+
server: { options: { keepalive: true } },
62+
continuous: { options: { keepalive: false } }
63+
},
5464

5565
karma: {
56-
unit: {
57-
options: testConfig('test/karma.conf.js')
58-
}
66+
unit: testConfig('test/karma.conf.js'),
67+
server: {configFile: 'test/karma.conf.js'},
68+
continuous: {configFile: 'test/karma.conf.js', background: true }
5969
},
6070

6171
jshint: {
@@ -107,6 +117,25 @@ module.exports = function(grunt) {
107117
dest: 'dist'
108118
}
109119
},
120+
121+
watch: {
122+
src: {
123+
files: ['src/*'],
124+
tasks: ['jshint:src', 'karma:unit:run', 'dist', 'build:gh-pages']
125+
},
126+
test: {
127+
files: ['test/*.js'],
128+
tasks: ['jshint:test', 'karma:unit:run']
129+
},
130+
demo: {
131+
files: ['demo/*', 'publish.js'],
132+
tasks: ['jshint', 'build:gh-pages']
133+
},
134+
livereload: {
135+
files: ['out/built/gh-pages/**/*'],
136+
options: { livereload: true }
137+
}
138+
}
110139
});
111140

112141
};

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
"devDependencies": {
1111
"angular-ui-publisher": "1.x",
1212
"grunt": "~0.4.x",
13+
"grunt-contrib-connect": "0.5.x",
1314
"grunt-contrib-jshint": "0.8.x",
1415
"grunt-contrib-uglify": "0.2.x",
16+
"grunt-contrib-watch": "0.5.x",
1517
"grunt-karma": "0.6.x",
1618
"grunt-ngmin": "0.0.x",
1719
"karma": "0.10.x",

0 commit comments

Comments
 (0)