0

I'm trying to follow along with a wordpress guide on Lynda.com that instructs me to use npm and Browser-Sync. Everything was working properly when I was working on a windows machine but I have recently setup a linux server (Ubuntu 16.04) and cannot seem to access the External URL Browser-Sync gives me. I am on the same network, and it does not work on any of my devices. I have the site setup to http://custom.local. Below is the Gulpfile.js I am using to initiate browser-sync.

var themename = 'custom';

var gulp = require('gulp'),
        // Prepare and optimize code etc
        autoprefixer = require('autoprefixer'),
        browserSync = require('browser-sync').create(),
        image = require('gulp-image'),
        jshint = require('gulp-jshint'),
        postcss = require('gulp-postcss'),
        sass = require('gulp-sass'),
        sourcemaps = require('gulp-sourcemaps'),

        // Only work with new or updated files
        newer = require('gulp-newer'),

        // Name of working theme folder
        root = '../' + themename + '/',
        scss = root + 'sass/',
        js = root + 'js/',
        img = root + 'images/',
        languages = root + 'languages/';


// CSS via Sass and Autoprefixer
gulp.task('css', function() {
        return gulp.src(scss + '{style.scss,rtl.scss}')
        .pipe(sourcemaps.init())
        .pipe(sass({
                outputStyle: 'expanded',
                indentType: 'tab',
                indentWidth: '1'
        }).on('error', sass.logError))
        .pipe(postcss([
                autoprefixer('last 2 versions', '> 1%')
        ]))
        .pipe(sourcemaps.write(scss + 'maps'))
        .pipe(gulp.dest(root));
});

// Optimize images through gulp-image
gulp.task('images', function() {
        return gulp.src(img + 'RAW/**/*.{jpg,JPG,png}')
        .pipe(newer(img))
        .pipe(image())
        .pipe(gulp.dest(img));
});

// JavaScript
gulp.task('javascript', function() {
        return gulp.src([js + '*.js'])
        .pipe(jshint())
        .pipe(jshint.reporter('default'))
        .pipe(gulp.dest(js));
});


// Watch everything
gulp.task('watch', function() {
gulp.task('watch', function() {
        browserSync.init({
                open: false,
                proxy: 'custom.local',
                port: 8080
        });
        gulp.watch([root + '**/*.css', root + '**/*.scss' ], ['css']);
        gulp.watch(js + '**/*.js', ['javascript']);
        gulp.watch(img + 'RAW/**/*.{jpg,JPG,png}', ['images']);
        gulp.watch(root + '**/*').on('change', browserSync.reload);
});


// Default task (runs at initiation: gulp --verbose)
gulp.task('default', ['watch']);

I've tried using different ports, and setting tunnel: true, and anything else I can find, but I'm getting a whole lot of nothing. Any assistance would be amazing.

Thank you,

1 Answers1

0

If you come across this and are having a similar issue, I just fixed it. I am using a headless environment so I didn't think to set up an entry in the hosts file.

/etc/hosts

127.0.0.1 custom.local