Gatsby: Add 'gatsby clean' to Gatsby CLI

Created on 22 May 2018  路  6Comments  路  Source: gatsbyjs/gatsby

Numerous times, I've faced issues and unexpected bugs due to cache not cleaned. Some of these include changes made not visible, runtime errors and so on. A regular fix for these seems be to clear the cache with rm -rf cache but I think since it's so commonly used, it'd help with it being a command in the Gatsby CLI itself.

So maybe a command like:
gatsby clean
Which would remove all the cache and later can build the project fresh.

question or discussion

Most helpful comment

I am interested in doing this

All 6 comments

I second this. Cache seems to be busted sometimes when creating/modifying content model in Contentful. Often enough that I run this script more often that the vanilla develop.

```sh
"cdev": "rm -rf .cache && npm run develop"

I would use rimraf npm package instead as rm is a Unix command.

I am interested in doing this

Yes. The cache is often problematic. It would actually be useful to be able to disable it:

yarn develop --nocache

But I'm guessing that isn't viable.

We know that cache is not bulletproof but instead of adding this feature to gatsby-cli, we actually would prefer to fix issues we have and not hide them (so we prefer people to create issues with descriptions allowing us to reproduce it). You still can use rm -rf .cache of course.

@pieh I think the problem is these issues tend to crop up late on in a project lifecycle when there is a lot going on in the way of plugins and custom code, making it really hard to isolate issues and give a useful report or isolate in a test-case. They are also often seemingly intermittent.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

totsteps picture totsteps  路  3Comments

benstr picture benstr  路  3Comments

andykais picture andykais  路  3Comments

signalwerk picture signalwerk  路  3Comments

kalinchernev picture kalinchernev  路  3Comments