Laravel-mix: hmrOptions in config.js

Created on 20 Jul 2018  路  5Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 2.0.0 (npm list --depth=0)
  • Node Version (node -v): 8.11.3
  • NPM Version (npm -v): 6.2.0
  • OS: Debian 9 Stretch

Description:

Within config.js I notice that hmrOptions {} are hard coded to only serve on localhost:8080.

Steps To Reproduce:

When developing on a remote system or virtual guest OS it would be good to have hmr run on the host/port specified by the run hot parameters such as:

$ npm run hot --host 192.168.56.2 --port 8080

Most helpful comment

All 5 comments

Use

mix.options({
    hmrOptions: {
      host: 'bla'
      port: 8081
    }
  })

I actually dropped this in, so it uses the --host option. But there's probably a tidier way.

/**
* Hostname and port used for the hot reload module
*
* @type {Object}
*/
hmrOptions: {
  host: (process.argv.includes('--host')) ? process.argv[process.argv.indexOf('--host')+1] : 'localhost',
  port: '8080'
},

But now I see @schniper comment which is more elegant and doesn't require source editing or a PR.

Totally agree that it should be added into the documentation

Laravel Mix documentation is now at laravel-mix.com.

Added a section about setting the hmrOptions with mix.options here.

Sorted thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sdebacker picture sdebacker  路  3Comments

Bomavi picture Bomavi  路  3Comments

jpmurray picture jpmurray  路  3Comments

RomainGoncalves picture RomainGoncalves  路  3Comments

hasnatbabur picture hasnatbabur  路  3Comments