Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe add an option to clean only when file's created date is older than e.g. 30 days. #8

Closed
joonhocho opened this issue Dec 20, 2015 · 3 comments

Comments

@joonhocho
Copy link

I think it will be useful when cached pages still requests for older assets.
What are your thoughts?

@johnagan
Copy link
Owner

johnagan commented Jan 8, 2016

Personally I'm 👎 on this, but if others feel strongly about it, I'm open to seeing a PR for it

@hassaans
Copy link

Imagine while a user's on your website and you deploy a new release. And then he moves to a page that used a dynamic import. It won't be able to find that chunk as it does not exist anymore.

@chrisblossom
Copy link
Collaborator

chrisblossom commented Mar 13, 2019

This is out of scope of this package.

If you are trying to keep old files, you'll need to write previous build assets to disk, then read the asset list and give the list to cleanOnceBeforeBuildPatterns / cleanAfterEveryBuildPatterns as negative patterns. Is fairly easily accomplished...look into webpack's done plugin hook. See also: clean-webpack-plugin.ts#L218-L234

But then again, you'll have a weird dev flow. You probably don't want the old build files in webpack's output.path directory.

A better solution than trying to keep a history build manifest would be to just copy all build files into a git-commited directory on release. Then after all cleaning / webpack build, copy the previous assets (be sure not to overwrite) back to webpack's output.path.

IMO, if this is what you are worried about, you should use a CDN and let them handle the caching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants