Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack compile only if changed

Tags:

webpack

My web project is primarily Python, but I am using Webpack to compile and compress my Javascript, and it is working quite nicely.

The compilation takes a good little bit, but that's both expected and acceptable. However, when I run my tests locally, the only way that I've found to ensure that I have the latest Javascript is to compile it.

This becomes a big problem the more I desire to test. Most of the time the code I'm packing hasn't changed, because that's not what I'm working on. So between test runs webpack's output won't change. I still have to incur the cost of packing, because I can't guarantee that it hasn't changed.

Is there a way for webpack to see if the source files have changed since the last pack was created, and only pack if the pack that already exists isn't from the same source files?

like image 270
Ryan Hiebert Avatar asked Nov 27 '15 17:11

Ryan Hiebert


1 Answers

There's no easy built-in way to do this, but someone wrote a plugin: only-if-changed-webpack-plugin. This checks the time on your entry file and also on all its dependencies and only rebuilds if something changed.

like image 133
Jim Stewart Avatar answered Oct 14 '22 11:10

Jim Stewart