webpack: Compile stuck at optimize chunk assets
I’ve started having problems to compile my build when --optimize-minimize
is enabled.
I see that I’ve reached +/-205 build modules, and then the compilation gets stuck at 80% optimize chunk assets
for a very long time (+40minutes).
If I wait enough, it ends up node failing with “fatal error: js allocation failed - process out of memory”
I guess it has to do with the uglifyjs plugin as I said this only happens when using --optimize-minime
flag (When compiling through my grunt task, this also fails).
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 88 (21 by maintainers)
Commits related to this issue
- [FIX] Replace ts-loader with awesome-typescript-loader Issue: https://github.com/webpack/webpack/issues/537 — committed to chrisber/react-bootstrap-formform by chrisber 8 years ago
@sokra Could you comment on why you closed this? Has a fix from uglify been pulled in to fix the problem with already-compiled files?
@fresheneesz: I added it to the UglifyJS plugin config as suggested a few posts up. I actually found the root cause of my problem, which may be what others were experiencing. It turns out I was using the
UglifyJsPlugin
in the config file but also runningwebpack -p
, so optimizing twice. When I removed the-p
from the CLI command, everything worked. More here: https://github.com/webpack/webpack/issues/1385#issuecomment-160553651If still getting stuck/crashing due to OOM at 78%, after removing any pre-minified assets, you may want to try running WebPack with more memory than Node’s default and a larger thread pool. You can use the UV_THREADPOOL_SIZE environment variable to set the size of the thread pool, and Node’s –max_old_space_size=SIZE_IN_MB argument to increase the Node’s memory limit.
For example:
Additionally, I use the following configuration for the UglifyJS plugin for production and it works fine when given enough resources as noted above…it just takes a good bit longer than desired:
I know much of this has been mentioned in this issue, but wanted to put the core workarounds that I found together in one place for people searching.
Increasing swap worked for me!
Regarding the original issue:
instead of
--optimize-minimize
or-p
should help…We’re also running into this issue and have worked-around exactly as @dougcalobrisi suggests. It’s slow, but at least it doesn’t die.
Try to remove
dev-tool: source-map
, then it will be much faster. But I’m still trying to figure out how can keepsource-map
.Using
Burns 100% of the cpu for >45minutes before I gave up and killed the process.
Running
uglifyjs
on webpack’s output completes in a matter of seconds.Have the same issue here, without UglifyJsPlugin. Do you have any idea when can this be fixed?
anyway. Thanks for the webpack! incredible pice of art.
Had this same issue, building was taking 10mins+ and as a few people have noted, i took out my minified dependencies and it now builds in ~10s 😄.