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

Fix #95: Makes whitenoise optional to install #100

Merged
merged 3 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading