Skip to content

Commit

Permalink
Merge pull request #130 from dmwyatt/patch-1
Browse files Browse the repository at this point in the history
Update README.md for rollup 4 hashes
  • Loading branch information
Niicck authored Apr 7, 2024
2 parents ff6d7a9 + 19ecae3 commit fee2efe
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,11 @@ If you are serving your static files with whitenoise, by default your files comp
```python
import re

# Vite generates files with 8 hash digits
# http://whitenoise.evans.io/en/stable/django.html#WHITENOISE_IMMUTABLE_FILE_TEST

def immutable_file_test(path, url):
# Match filename with 12 hex digits before the extension
# e.g. app.db8f2edc0c8a.js
return re.match(r"^.+[\.\-][0-9a-f]{8,12}\..+$", url)
# Match vite (rollup)-generated hashes, à la, `some_file-CSliV9zW.js`
return re.match(r"^.+[.-][0-9a-zA-Z_-]{8,12}\..+$", url)


WHITENOISE_IMMUTABLE_FILE_TEST = immutable_file_test
Expand Down

0 comments on commit fee2efe

Please sign in to comment.