The issue is that I cannot seem to get webpack to treat the elm code any differently than the rest of the js I have. Would anyone mind sharing their config if they managed to achieve something similar? Particularly if they have a codebase with a mix of elm and non elm code to be uglified.
It is also worth noting that if you have a mixture of Elm and other JS code, it’ll be dangerous to run the whole thing through uglify like that - unless I’m mistaken those options could potentially result in your JS getting messed up.
That will split your code into two files - one with your elm, one with everything else. you can then have two uglify runs with different options - one over each file:
That was very helpful, I didn’t understand how to use dynamic imports previously.
I just tried it out now and it seems that creating separate chunks and uglifying the code as you suggested actually generated a slightly larger total file size! I am not sure why that is the case, but seems that we will stick with the default settings for now then.
Perhaps this is because the elm component is only a small part of the total js for that page
Without chunking + default uglify
247,787 bytes
With chunking + elm compression settings
226,032 + 22,088 = 248,120 bytes