Skip to content
This repository was archived by the owner on Apr 30, 2018. It is now read-only.

Commit ea8b05e

Browse files
committed
Added grunt watcher
'grunt dev' watches the files in /src and causes the browser to refresh
1 parent 4134197 commit ea8b05e

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

Gruntfile.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,25 @@ module.exports = function(grunt) {
44
// Project configuration.
55
grunt.initConfig({
66
pkg: grunt.file.readJSON('package.json'),
7+
formlyConfig: {
8+
hostname: 'localhost', // change to 0.0.0.0 to listen on all connections
9+
base: 'src',
10+
port: 4000,
11+
livereloadport: 35701
12+
},
713
connect: {
814
dev: {
915
options: {
10-
port: 4000,
11-
base: 'src',
12-
keepalive: true
13-
},
16+
hostname: '<%= formlyConfig.hostname %>',
17+
port: '<%= formlyConfig.port %>',
18+
base: '<%= formlyConfig.base %>',
19+
livereload: '<%= formlyConfig.livereloadport %>'
20+
}
1421
}
1522
},
1623
'gh-pages': {
1724
options: {
18-
base: 'src'
25+
base: '<%= formlyConfig.base %>'
1926
},
2027
src: ['**']
2128
},
@@ -27,7 +34,7 @@ module.exports = function(grunt) {
2734
files: [
2835
{
2936
expand: true,
30-
cwd: 'src/',
37+
cwd: '<%= formlyConfig.base %>/',
3138
src: ['directives/formly*.*', 'modules/formly*.*', '!.jshintrc'],
3239
dest: '.tmp/'
3340
}
@@ -86,6 +93,14 @@ module.exports = function(grunt) {
8693
src: '.tmp/formly.js',
8794
dest: '.tmp/formly.js'
8895
}
96+
},
97+
watch: {
98+
livereload: {
99+
files: ['<%= formlyConfig.base %>/**/*.{js,html}'],
100+
options: {
101+
livereload: '<%= formlyConfig.livereloadport %>'
102+
}
103+
}
89104
}
90105
});
91106

@@ -98,13 +113,15 @@ module.exports = function(grunt) {
98113
grunt.loadNpmTasks('grunt-gh-pages');
99114
grunt.loadNpmTasks('grunt-angular-templates');
100115
grunt.loadNpmTasks('grunt-ngmin');
116+
grunt.loadNpmTasks('grunt-contrib-watch');
101117

102118
grunt.registerTask('publish', [
103119
'gh-pages'
104120
]);
105121

106122
grunt.registerTask('dev', [
107-
'connect:dev'
123+
'connect:dev',
124+
'watch'
108125
]);
109126

110127
grunt.registerTask('build', [

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
],
2727
"dependencies": {
2828
"angular": "~1.2.10",
29-
"bootstrap": "~3.1.0"
29+
"bootstrap": "~3.1.1"
3030
},
3131
"devDependencies": {
3232
"angular-ui-router": "#0.2.8-bowratic-tedium",

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"grunt-ngmin": "0.0.3",
1515
"grunt-contrib-copy": "~0.5.0",
1616
"grunt-contrib-clean": "~0.5.0",
17-
"grunt-contrib-uglify": "~0.3.2"
17+
"grunt-contrib-uglify": "~0.3.2",
18+
"grunt-contrib-watch": "~0.6.1",
19+
"connect-livereload": "~0.4.0"
1820
}
1921
}

0 commit comments

Comments
 (0)