Skip to content

Instantly share code, notes, and snippets.

@ronalson
Last active August 22, 2017 19:53
Show Gist options
  • Save ronalson/b014c1f9db8a522786584e7c35b57878 to your computer and use it in GitHub Desktop.
Save ronalson/b014c1f9db8a522786584e7c35b57878 to your computer and use it in GitHub Desktop.
Add Browser-sync to Rails
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