Laravel Mix 'watch' not compiling when webpack.mix.js updated
Asked Answered
K

1

3

When I run npm run watch and update my source .js and .scss assets, the compilation is run automatically as expected. When I update the webpack.mix.js file, the changes are NOT compiled automatically.

Is this something that v6 doesn't support? Because v5 did work as expected.

The config:

const mix = require('laravel-mix')

mix.js('resources/js/app.js', 'public/js')
  .sass('resources/css/app.scss', 'public/css')
  .version()

package.json:

{
  ...

  "scripts": {
    "development": "mix",
    "watch": "mix watch",
    "watch-poll": "mix watch -- --watch-options-poll=1000",
    "hot": "mix watch --hot",
    "production": "mix --production"
  }

  ...
}
Kaleighkalends answered 10/2, 2021 at 13:29 Comment(2)
Did you tryied to stop the watch and run it again?Estimation
Yes. Also tried different OS's to no avail.Kaleighkalends
C
4

Weird, it works for me. Try npm run watch-poll instead. You should be running the latest version of Laravel Mix:

"laravel-mix": "^6.0.11",

Unrelated, you may want to update your package.json file to the following if you're using Laravel Mix 6.

"scripts": {
    "dev": "npm run development",
    "development": "mix",
    "watch": "mix watch",
    "watch-poll": "mix watch -- --watch-options-poll=1000",
    "hot": "mix watch --hot",
    "prod": "npm run production",
    "production": "mix --production"
},

According to the 8.x Laravel documentation...

Webpack may not be able to detect your file changes in certain local development environments. If this is the case on your system, consider using the watch-poll command.

Cyndy answered 10/2, 2021 at 14:5 Comment(1)
That's basically my current setup.Kaleighkalends

© 2022 - 2024 — McMap. All rights reserved.