Reputation: 394
I'm trying to run the example from an npm package that uses parcel.
The example uses a url that makes an api call.
To run the example I do: npm test
Below are the 2 attempts that I made to stop the caching. I modify the index.js, kill the local server and restart and it caches no matter what. I'm just looking to run the example and make changes and see the results. It is obviously using the dist folder, but I keep deleting things, but the issue still persists. Any suggestions would be appreciated. Feel free to ask why would I ever want to do this.
package.json
"scripts": {
"test": "parcel example/index.html --no-cache",
"patch": "npm version patch --no-git-tag-version",
"minor": "npm version minor --no-git-tag-version",
"major": "npm version major --no-git-tag-version"
}
Upvotes: 5
Views: 5762
Reputation: 6062
It seems that although --no-cache
technically does disable Parcel's aggressive caching, in practice it requires a few more awkward steps to actually see any new changes you've made.
In addition to running parcel
with the --no-cache
option, you also need to close any current instances of the parcel
local server, and also need to bypass the browser cache by doing a hard refresh (CtrlShiftR in Firefox).
Upvotes: 5
Reputation: 5932
I ran into a similar problem and thus use the following scripts in package.json
to ensure that I have no leftovers from previous builds. Unfortunately, this does still require rerunning the npm run dev
command whenever I want to have a clean setup:
"scripts": {
"build": "rm -rf dist .parcel-cache && parcel build src/index.html",
"dev": "rm -rf dist-dev .parcel-cache && parcel --dist-dir dist-dev src/index.html"
}
Upvotes: 5
Reputation: 3777
The docs for the --no-cache
flag say:
Caching can also be disabled using the --no-cache flag. Note that this only disables reading from the cache – a .parcel-cache folder will still be created.
So my hunch is that it's working as expected. In most contexts it's totally fine to allow parcel to create a .parcel-cache
folder (although it's best practice to add this folder to .gitignore
). Is there something about your context that makes this a problem?
Upvotes: 0