Search code examples
brunch

How to clean output folder before build using Brunch.io


I'm using brunch.io and it works great.

The only thing I don't know how to achieve is to have a clean before build.

For example, if I brunch build it creates source maps. If I do brunch build --production it doesn't create source maps. However, the source maps that were already there are not deleted.

Is there any option / plugin to clean? Should I use npm clean in some other place?


Solution

  • If you need a clean pass, I would suggest to just remove the public directory.

    rm -rf public/ && brunch build -P

    You can add it to package.json like that:

    "scripts": { "build": "rm -rf public/ && brunch build -P" },

    and then just do npm run build instead of brunch build -P