grunt-webpack icon indicating copy to clipboard operation
grunt-webpack copied to clipboard

Webpack incremental build does not work

Open Leekao opened this issue 1 year ago • 4 comments

According to Webpack5 documentation in order to utilize incremental build I need to pass cache object with type: "filesystem" however that does nothing when I pass it through Grunt-webpack and the documentation for Grunt-webpack refer to cache as a Boolean.

Leekao avatar Dec 21 '24 14:12 Leekao

If anyone in the future wonders how I resolved this issue the solution for me was to remove grunt-webpack and to run webpack from cli using grunt-shell and it indeed builds incrementally.

Leekao avatar Dec 23 '24 20:12 Leekao

Makes sense. Grunt suppress output and input a lot more than needed. Like error handling.

evenstensberg avatar Dec 23 '24 20:12 evenstensberg

I found the problem, this is a straight up bug in grunt-webpack: grunt-webpack never calls compiler.close(), see a description of the issue in webpack's issue tracker https://github.com/webpack/webpack/issues/12342#issuecomment-754869202

If you look in tasks/webpack.js you can see that compiler is created as const compiler = webpack(webpackOptions);, but compiler.close() is never called. In Webpack 5, compiler.close() is what triggers webpack to write out the filesystem cache before exiting.

snickell avatar Nov 06 '25 05:11 snickell

Here's a PR with a fairly simple fix that WorksForMe(TM): https://github.com/webpack/grunt-webpack/pull/250

This makes webpack 5 caching work with grunt-webpack.

snickell avatar Nov 06 '25 08:11 snickell