I have a very simple project set up to use Parcel as the bundler. It's just the basic example from their Getting Started guide.
For a single build everything works fine but I noticed that for every build the javascript code is compiled under a new hash. This can result in multiple JS hashes being created in the dist/
directory. Is there a way to clear everything from dist/
before every build so that it only contains the latest code?
One option that requires little setup and is cross-platform would be to use a plugin like parcel-plugin-nuke-dist. Just install it and it will clear the dist/
dir before every build:
npm install parcel-plugin-nuke-dist --save-dev
NOTE: parcel-plugin-nuke-dist
isn't compatible with Parcel v2, please see the other answers for alternatives