Skip to content
Advertisement

How to remove folder with npm before build

I’ve got a scripts "build": "rimraf dist webpack --progress --config webpack/prod.js", But actually,it removed not dist but all file inside webpack folder. But I need delete only dist

Structure:
 -dist
 -webpack
     -somefiles.js

Advertisement

Answer

Npm scripts are basically the same as running the commands directly in bash. In your case, you are running rimraf dist webpack which means webpack is an argument for rimraf. To separate commands, you can use ; or & if you want to make sure the first command ran successfully before running the second one use && So your script should look like this.

rimraf dist && webpack --progress --config webpack/prod.js

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement