When using webpacker with Rails,
webpack assets from
public/packs folder usually occupy a lot of disk space.
it is important
to clean up disk space time to time
we can use clean webpack plugin
to clean packs automatically.
Rails 6 supports
Rails 5.1 had merged webpacker in Rails
we had to use
as an asset pipeline with Rails.
public/packs occupies huge disk space
As we have been using
webpacker with Rails
compile directory as
every time server boots up
we make any changes
it compiles webpack assets.
This occupies huge space. There are a couple of approaches that can be used to clean up such files.
1. Webpack clobber assets
One of the solution is to, clean up using rake task provided as given below.
This will clean up directory that is use for outputting compiled webpack assets. But, again this is a manual effort and we need to invoke this rake task often to clean up disk space.
Clean up webpack plugin
1. Add clean-webpack-plugin
Add clean-webpack-plugin as given below.
2. Add plugin to development.js
We need to add this plugin to
Once this change is in place, whenever webpack compiles assets, it will only generate new files.
Thus, the directory won’t occupy a lot of space by not having older webpack compiled assets in the directory which are not required.
Subscribe to Ruby in Rails
Get the latest posts delivered right to your inbox