Created
January 22, 2016 14:26
-
-
Save wnstn/36010c8378e850cc3580 to your computer and use it in GitHub Desktop.
Rails, Gulp, and Browsersync together at last
This file contains hidden or 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'], ['reload']); | |
gulp.watch(['./app/assets/stylesheets/**/*.scss'], ['reloadCSS']) | |
}; | |
gulp.task('reload', function(){ | |
return browserSync.reload(); | |
}); | |
gulp.task('reloadCSS', function() { | |
return browserSync.reload('*.css'); | |
}); | |
gulp.task('init', function() { | |
browserSync.init({ | |
proxy: 'localhost:7999', | |
port: 8000, | |
open: false, | |
ui: { | |
port: 8001 | |
} | |
}); | |
setupWatchers(); | |
}); | |
gulp.task('default', ['init']); |
@bsodmike @jonathan-soifer so sorry, i didn't see notifications here. If you're running on default rails port change this block to this:
gulp.task('init', function() {
browserSync.init({
proxy: 'localhost:3000',
port: 3001,
open: false,
ui: {
port: 3002
}
});
and then you can access browsersync at localhost:3001
Hey @wnstn the original port config was fine, all I needed to do was bind my rails server. I found that it would sometimes (locally) jump to ipv6, but binding seems to take care of that.
+gulp.task('init', function() {
+ browserSync.init({
+ proxy: '0.0.0.0:3000',
+ port: 8000,
+ open: false,
+ ui: {
+ port: 8001
+ }
+ });
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Success! @jonathan-soifer Just start your local rails server whilst binding to
0.0.0.0
usingrails s -b 0.0.0.0
. I also set the proxy port as 8080.