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

feat: Allow static file config options #65

Merged

Conversation

cj
Copy link
Contributor

@cj cj commented Jan 2, 2025

Description

This allows you to set things like the cache_control for the static paths to improve lighthouse scores.

from litestar.datastructures import CacheControlHeader
from litestar_vite import ViteConfig, VitePlugin
from litestar_vite.plugin import StaticFilesConfig

VitePlugin(
        config=ViteConfig(
            hot_reload=env.debug,
            use_server_lifespan=env.debug,
            dev_mode=env.debug,
            port=env.vite_port,
        ),
        static_files_config=StaticFilesConfig(
            cache_control=CacheControlHeader(max_age=31536000, immutable=True, public=True),
        ),
    )

Copy link
Member

@cofin cofin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the enhancement! LGTM

@cofin cofin merged commit 9c0a016 into litestar-org:main Jan 4, 2025
17 checks passed
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

Successfully merging this pull request may close these issues.

2 participants