Skip to content

feat(vite): re-export ViteConfig from vite package root#136

Merged
bedus-creation merged 11 commits into
mainfrom
feature/export-viteconfig
Jun 20, 2026
Merged

feat(vite): re-export ViteConfig from vite package root#136
bedus-creation merged 11 commits into
mainfrom
feature/export-viteconfig

Conversation

@bedus-creation

@bedus-creation bedus-creation commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes from fastapi_startkit.vite import ViteConfig work by re-exporting ViteConfig from the vite package root, and updates the Vite example app to the new templates convention.

Changes

  • vite/__init__.py: import ViteConfig from .config.vite and add it to __all__ (alongside the existing exports). No behavior change beyond the export.
  • tests/vite/test_vite.py: add TestViteConfigExport asserting the import works, resolves to the SAME class object as fastapi_startkit.vite.config.vite.ViteConfig, and is present in __all__.

Vite example app (example/vite-app)

  • Moved templates/index.htmlresources/templates/index.html to match ViteConfig.templates_directory default (resources/templates).
  • Dropped the templates_directory="templates" override in bootstrap/application.py; the example now relies on ViteProvider's auto-bound Jinja2Templates engine at the default directory.
  • Route already resolves templates via the framework-level template() helper (decoupled from bootstrap.application); the manual Jinja2Templates binding in providers/fastapi_provider.py was already removed earlier on this branch.

Verification

  • uv run pytest tests/vite/ -v → 41 passed
  • uv run pytest --cov → 1558 passed, coverage 67.29% (above fail_under)
  • Example app boots end-to-end (TestClient): GET / → 200, templates auto-bound from resources/templates, vite/vite_asset/vite_react_refresh Jinja globals present and the vite() directive renders (no unrendered {{ vite }}); GET /api/health → 200.

Example app: tests + structure (follow-up)

  • Added simple HTTP tests in example/vite-app/tests/ using the framework's HttpTestCase: GET /api/health → 200 JSON, and GET / renders the index template (templates from resources/templates, vite() directive resolved). Added pytest.ini and dev deps (pytest, pytest-asyncio, httpx). uv run pytest -v → 2 passed.
  • Moved providers/app/providers/ (grouped under an app/ package) and updated the bootstrap import accordingly.

…vider default

Move the example templates into resources/templates to match ViteConfig's
default templates_directory, and drop the bootstrap override so the example
relies on ViteProvider's auto-bound Jinja2Templates engine.
Use `from fastapi_startkit.application import app` -> app().make('templates')
in the example route instead of the bootstrap module, matching the framework's
canonical app accessor (no top-level export).
Relocate providers/ to app/providers/ and update the bootstrap import,
grouping application code under the app/ namespace.
Add HttpTestCase-based tests covering the health endpoint and the index
page render (templates resolve from resources/templates with vite globals).
Wire up pytest config and dev dependencies.
Resolve conflicts in vite-app bootstrap/application.py and routes/web.py,
keeping the app/ provider package layout and canonical app() template
accessor. Restore FastAPIProvider without the stale templates binding so
ViteProvider serves templates from resources/templates.

Remove tests/vite/test_vite.py per request.
Rely on the built manifest so the vite() directive resolves to
production asset URLs, and drop the dev-server hot file setup. Assert
against the built /build/assets/ output instead of the source path.
Also remove the stale ViteProvider comment in bootstrap.
Match the routes/web.py module and the TestWebRoutes class it covers.
Keep the index page test focused on a successful render.
@bedus-creation bedus-creation merged commit f313317 into main Jun 20, 2026
3 checks passed
@bedus-creation bedus-creation deleted the feature/export-viteconfig branch June 20, 2026 20:38
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.

1 participant