browserSync elixir in laravel skips opened assigned port


#1

Hi, Ive installed laravel and setup elixir’s broserSync, including the ports.conf to 8082 and the site-enabled/available to the same port, and specified root. Problem is, when running browserSync, the assigned port skips to 8083… And the same will occur if port 8081 is open; skipping to 8082(being closed).


#2

hi, my code is worked :slight_smile:
If you use BrowserSync with team, you can set environment variables

mix.browserSync({
    proxy: 'localhost:8080', // https://workspacename-yourname.c9users.io
    port: 8081, // https://workspacename-yourname.c9users.io::8081 (BrowserSync URL)
    // If you need Sync Setting Screen.
    // https://workspacename-yourname.c9users.io::8082
    ui: {
        port: 8082
    }
});

reference
Laravel Elixir Browsersync Support
Available ports on a hosted Cloud9 workspace
option-port
option-ui
Problem setting environment variables


#3

In the final case of me

// browserSync
// export SYNC_PROXY=localhost:8080  app url
// export SYNC_PORT=8081                    browserSync use port
// export SYNC_UI_PORT=8082               browserSync setting port
// export SYNC_RELOADDELAY=0          reloadDelay
// 
// https://workspacename-username.c9users.io:8080 usual
// https://workspacename-username.c9users.io:8081 BrowserSync
// https://workspacename-username.c9users.io:8081 BrowserSync setting screen
if (typeof process.env.SYNC_PROXY !== "undefined" && typeof process.env.SYNC_PORT !== "undefined" && typeof process.env.SYNC_UI_PORT !== "undefined") {
    mix.browserSync({
        files: [
            `resources/assets/pc/sass`,
            `resources/assets/sp/sass`,
            'resources/views/**/*'
        ],
        proxy: process.env.SYNC_PROXY,
        port: Number(process.env.SYNC_PORT),
        ui: {
            port: Number(process.env.SYNC_UI_PORT)
        },
        reloadOnRestart: true,
        reloadDelay: Number(process.env.SYNC_RELOADDELAY || 0)
    });
}

reference
option-files(page refresh)
Reload each browser when Browsersync is restarted.