Skip to content

Commit

Permalink
Fix #95: Makes whitenoise optional to install (#100)
Browse files Browse the repository at this point in the history
Makes whitenoise optional to install

Fix #95
  • Loading branch information
jpsca authored Oct 19, 2024
1 parent da33e70 commit ba7c89e
Show file tree
Hide file tree
Showing 6 changed files with 304 additions and 267 deletions.
11 changes: 10 additions & 1 deletion docs/content/guide/css_and_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ The tags above will not work if your application can't return the content of tho

For that reason, JinjaX includes WSGI middleware that will process those URLs if you add it to your application.

**This is not needed if your components doesn't use static assets or if you serve them by other means.**

```py
from flask import Flask
from jinjax import Catalog
Expand All @@ -138,7 +140,14 @@ app.wsgi_app = catalog.get_middleware(
)
```

The middleware uses the battle-tested [Whitenoise library](http://whitenoise.evans.io/) and will only respond to the *.css* and *.js* files inside the component(s) folder(s). You can configure it to also return files with other extensions. For example:
The middleware uses the battle-tested [Whitenoise library](http://whitenoise.evans.io/) and will only respond to the *.css* and *.js* files inside the component(s) folder(s).
Yo must install it first:

```bash
pip install jinjax[whitenoise]
```

Then, you can configure it to also return files with other extensions. For example:

```python
catalog.get_middleware(app, allowed_ext=[".css", .js", .svg", ".png"])
Expand Down
6 changes: 0 additions & 6 deletions package-lock.json

This file was deleted.

Loading

0 comments on commit ba7c89e

Please sign in to comment.