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

SPA provider (vite) #1257

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

SPA provider (vite) #1257

wants to merge 15 commits into from

Conversation

Milo123459
Copy link
Collaborator

@Milo123459 Milo123459 commented Jan 10, 2025

  • vite spa provider
  • also use out directory if specified in the build command
  • vite spa provider

This PR introduces a Vite SPA provider which will automatically run supported applications with Caddy.

It can be configured via NIXPACKS_SPA_CADDY to turn off Caddy, or if you want to turn Caddy on for an application that doesn't automatically get detected, you can specify a build directory with the NIXPACKS_SPA_OUT_DIR variable.

Detection

Vite is detected by:

  • vite dependency
  • vite.config.js or vite.config.ts
  • build script contains vite build

Output directory:

  • if outDir is in vite.config.js/ts
  • if --outDir is in the build script

Caddy:

  • These dependencies are detected:
    • react
    • vue
    • svelte (but not @sveltejs/kit)
    • preact
    • lit
    • solid-js
    • @builder.io/qwik
  • Tests are added/updated if needed
  • Docs are updated if needed

@Milo123459 Milo123459 added the release/minor Author minor release label Jan 10, 2025
@Milo123459
Copy link
Collaborator Author

no idea why the lunatic one is failing

@Milo123459 Milo123459 requested a review from coffee-cup January 14, 2025 16:17
Copy link
Contributor

@coffee-cup coffee-cup left a comment

Choose a reason for hiding this comment

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

Nice work! This will definitely make it easier for people coming from Vite apps.

Do you know how this will interact with users who have a custom nixpacks.toml and Caddy file for deploying static sites already?

src/providers/node/mod.rs Outdated Show resolved Hide resolved
src/providers/node/mod.rs Show resolved Hide resolved
src/providers/node/mod.rs Outdated Show resolved Hide resolved
src/providers/node/spa/vite.rs Show resolved Hide resolved
@Milo123459
Copy link
Collaborator Author

I'm not sure, but the Caddyfile wouldn't overwrite the users. And im pretty sure it would just use what's in nixpacks.toml as opposed to what the SPA provider generates.

@Milo123459 Milo123459 requested a review from coffee-cup January 15, 2025 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/minor Author minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants