How can I get gulp + browsersync to work apache vhost?

I would like to add gulp, sass and browsersync to my toolkit. Now I run gulp with sass and browsersync settings.

I am hiding a php application running from vhost on my local Apache server.

I am trying to start browsersync from a view task using the browserersync proxy option to use my vhost.

Currently, when I start the clock, the server cannot be found on port 3000. If I go to "localhost: 3000", I get an error message without a web page.

If I go to port 3001, I can access the browser admin interface. Therefore, I know that the browser is working.

My gulp conf is as follows

/* load plugins */ var gulp = require('gulp'), sass = require('gulp-ruby-sass'), browsersync = require('browser-sync') ; /* * define tasks */ gulp.task('sass', function() { return sass('assets/sass/main.sass') ; }) ; /* * browsersync conf */ gulp.task('browser-sync', function() { browsersync({ proxy: 'localhost', port: '3000' }); }); gulp.task('browsersync-reload', function () { browsersync.reload(); }); gulp.task('watch', ['browser-sync'], function () { gulp.watch('assets/sass/**/*', ['css']); }); /* Default task */ gulp.task('default', ['sass'], function() { gulp.watch("assets/sass/**.*", ['sass']); }); 
+5
source share
3 answers

If you installed apache (masked sample), you must configure the port to 8080

My configuration:

  browserSync.init({ open: 'external', host: 'local.dev', proxy: 'local.dev', port: 8080 // for work mamp }); 
+4
source

The BrowserSync "proxy" parameters should indicate where your Apache server is serving your application, and not where you want to access it.

For example, if I run a ruby ​​server on localhost: 9000, I would indicate that the proxy options and access are through the browser through a URL that browsers will display to me through the command line

+3
source

use this instead, add vhost for example. mysite.local

then

 gulp.task('server', function() { browserSync.init({ proxy: "mysite.local" }); }); 
-1
source

Source: https://habr.com/ru/post/1215853/


All Articles