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
rimraf
using eithernpm
oryarn
:npm install rimraf --save-dev
OR
yarn add rimraf --dev
-
In the
scripts
section of of yourpackage.json
file, userimraf
in the following way:"scripts": { "clean:build": "rimraf /path/to/builddir/*" }
-
Now simply use either
npm
oryarn
to run the command to clear out your build directory:npm run clean:build
OR
yarn run clean:build