Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

s.lavoie.b@gmail.com's avatar

How can I run `npm run production`only when the mix-manifest changed?

I am currently running npm run production in my deploy process. However, the build process does take some time and it runs regardless of what is being deployed.

So my question is, how can I run npm run productiononly when the mix-manifest changed?

0 likes
3 replies
topvillas's avatar

I don't think you can. How would webpack know if the manifest has changed?

The best you can do is write a node module that saves a copy of the manifest when it's run and do a diff on the current manifest. Or saves a date to a file and checks it against the last updated date of the current manifest.

s.lavoie.b@gmail.com's avatar

I don't know that much about weback and all, so the idea of writing a node module sounds pretty dreadful to me.

I am using Laravel Forge though, it does a git pull before running npm run production, so maybe forge should be responsible of finding out if the file is different?

topvillas's avatar

If you're writing Javascript then you can write a Node module.

Or run your production build before you deploy.

Please or to participate in this conversation.