简体   繁体   中英

How do I run "npm run watch" on specific address and port? (Laravel mix)

How can I run npm watch with a specific url and port?

In my package.json file I have following the line

"watch": "mix watch",

in the scripts section, which works fine with the command npm run watch and is accessed via localhost. I would like to access it at http://dev.myproject:8888 instead of localhost, as I have a number of projects.

To run npm start with a specific local url is can add the following line to the "scripts" section of my projects package.json:

"start": "http-server -a dev.myprojectname -p 8888"

(in order to this one must add dev.myprojectname to your "hosts" file, connected to 127.0.0.0)

How can I specify the same for npm watch ?

I have tried the same under watch ie:

"watch": "http-server -a dev.myprojectname -p 8888"

but this is not correct

I've stumbled upon the same question, so I will answer for posterity.

To pass args directly to webpack, -- --port <PORT> did the trick.

    "watch": "mix watch --hot -- --port 3080",

Hope it helps someone;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM