When working on a project, you are going to need to keep clearing out your build directory that contains the code you plan to deploy, since you will be continuously updating your code. Instead of doing this manually, you can use a handy utility called rimraf and script the files you want to remove. Here’s how to use it.
-
In your project’s directory, install
rimrafusing eithernpmoryarn:npm install rimraf --save-devOR
yarn add rimraf --dev -
In the
scriptssection of of yourpackage.jsonfile, userimrafin the following way:"scripts": { "clean:build": "rimraf /path/to/builddir/*" } -
Now simply use either
npmoryarnto run the command to clear out your build directory:npm run clean:buildOR
yarn run clean:build