seadev left a reply on How To Use Watch Production In The New Laravel Mix?
Does this still work? I have a L5.4 project that I've added the new script to and and while it watches and reacts to saves/changes, it only minifies on the first initial run.
So I tried a brand new L5.5 project. Added the npm script above and set one css file to minify and experience the same thing.
A simple webpack.mix.js:
npm run watch-production
Again the initial build minifies but subsequent changes to test.css are not minified.
I recently ran into this problem as well and wanted to share what I learned here since this is one of the top results in a Bing/Google search.
Chances are if you're running into this your running on a multi-threaded web server and it wasn't an issue until there where multiple people hitting the server.
Long story short, using the dotenv package that Laravel uses isn't thread safe. You can see a discussion about it here: https://github.com/vlucas/phpdotenv/issues/76
The quick fix is to run: artisan config:cache
And I highly recommend adding a comment line to the top of your .env file:
I hope this helps.