How do you trim stack compilation artifacts

I am not super familiar with stack so consider this a guide more than an answer

First, you can run stack build --only-snapshot or similar flags to get all the online packages instead of listing them all.

After that, I think, they should be register and precompiled in some folder like .stack/snapshots/.... I think, that is the folder which contains all necessary artifacts to build you project so you can delete the intermidate .stack-work which has been created in the build directory.

I don’t know if the above is true, or if it will actually reduce the size of the image.