Skip to content
This repository was archived by the owner on Feb 5, 2022. It is now read-only.

Commit e668b01

Browse files
authored
Replace livereload with Browsersync (#639)
1 parent 02d9f13 commit e668b01

File tree

7 files changed

+21
-8
lines changed

7 files changed

+21
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $ cd /path/to/project-name
3030
$ gulp
3131
```
3232

33-
To test it visit `http://localhost:8080/` in your browser.
33+
To test it visit `http://localhost:3000` in your browser.
3434

3535
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3636

gulp/config.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
paths = require './paths'
22

33
config =
4+
host: "127.0.0.1"
5+
port: "8080"
46
ext: [
57
"#{paths.static.ext}/jquery/dist/jquery.js"
68
"#{paths.static.ext}/moment/moment.js"

gulp/tasks/build.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
gulp = require('gulp-help') require 'gulp'
22
yargs = require 'yargs-parser'
33
$ = require('gulp-load-plugins')()
4+
config = require '../config'
45
paths = require '../paths'
56

67

@@ -55,6 +56,12 @@ gulp.task 'run',
5556
else
5657
options_str += " -#{k} #{options[k]}"
5758

59+
if options['p']
60+
config.port = options['p']
61+
if options['o']
62+
config.host = options['o']
63+
64+
gulp.start('browser-sync')
5865
gulp.src('run.py').pipe $.start [{
5966
match: /run.py$/
6067
cmd: "python run.py #{options_str}"

gulp/tasks/watch.coffee

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
gulp = require('gulp-help') require 'gulp'
2+
browserSync = require('browser-sync')
23
$ = require('gulp-load-plugins')()
4+
config = require '../config'
35
paths = require '../paths'
46

57

6-
gulp.task 'reload', false, ->
7-
$.livereload.listen 35729
8+
gulp.task 'browser-sync', false, ->
9+
browserSync.init
10+
proxy: "#{config.host}:#{config.port}"
11+
notify: false
812
$.watch [
913
"#{paths.static.dev}/**/*.{css,js}"
1014
"#{paths.main}/**/*.{html,py}"
1115
], events: ['change'], (file) ->
12-
$.livereload.changed file
16+
browserSync.reload()
1317

1418

1519
gulp.task 'ext_watch_rebuild', false, (callback) ->

gulpfile.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ $ = require('gulp-load-plugins')()
66
gulp.task 'default',
77
'Start the local server, watch for changes and reload browser automatically.
88
For available options refer to "run" task.',
9-
$.sequence 'run', ['watch', 'reload']
9+
$.sequence 'run', ['watch']

main/templates/bit/script.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# if config.DEVELOPMENT
22
<script src="/p/dev/script/ext.js?{{config.CURRENT_VERSION_ID}}"></script>
33
<script src="/p/dev/script/script.js?{{config.CURRENT_VERSION_ID}}"></script>
4-
<script src="http://{{request.host.split(':')[0]}}:35729/livereload.js"></script>
54
# else
65
<script src="/p/min/script/ext.js?{{config.CURRENT_VERSION_ID}}"></script>
76
<script src="/p/min/script/script.js?{{config.CURRENT_VERSION_ID}}"></script>

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
},
99
"scripts": {
1010
"install": "gulp init",
11-
"postinstall": "echo 'Run `gulp` to start or `gulp help` for more.'"
11+
"postinstall": "echo 'Run `gulp` to start or `gulp help` for more.'",
12+
"start": "gulp"
1213
},
1314
"devDependencies": {
15+
"browser-sync": "2.18.8",
1416
"bower": "1.8.0",
1517
"coffee-script": "1.12.4",
1618
"del": "2.2.2",
@@ -23,7 +25,6 @@
2325
"gulp-help": "1.6.1",
2426
"gulp-if": "2.0.2",
2527
"gulp-less": "3.3.0",
26-
"gulp-livereload": "3.8.1",
2728
"gulp-load-plugins": "1.5.0",
2829
"gulp-plumber": "1.1.0",
2930
"gulp-sequence": "0.4.6",

0 commit comments

Comments
 (0)