Last active
August 22, 2017 19:53
-
-
Save ronalson/b014c1f9db8a522786584e7c35b57878 to your computer and use it in GitHub Desktop.
Add Browser-sync to Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var browserSync = require('browser-sync').create(); | |
var setupWatchers = function() { | |
gulp.watch(['./app/views/**/*.erb', | |
'./app/assets/javascripts/**/*.js', | |
'./app/assets/stylesheets/**/*.scss'], ['reload']); | |
}; | |
gulp.task('reload', function(){ | |
return browserSync.reload(); | |
}); | |
gulp.task('init', function() { | |
browserSync.init({ | |
proxy: { | |
target: "localhost:3000", | |
proxyReq: [ | |
function(proxyReq) { | |
proxyReq.setHeader('X-Forwarded-Host', 'localhost:8000'); | |
} | |
], | |
}, | |
port: 8000, | |
open: true, | |
ui: { | |
port: 8001 | |
} | |
}); | |
setupWatchers(); | |
}); | |
gulp.task('default', ['init']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment