mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-06 12:57:46 +00:00
Adds support for Remix apps which use the new Remix Vite plugin. * The vanilla Remix + Vite template deploys correctly out-of-the-box, however only a single Node.js function will be used, and a warning will be printed saying to configure the `vercelPreset()` Preset. * When used in conjunction with the `vercelPreset()` Preset (https://github.com/vercel/remix/pull/81), allows for the application to utilize Vercel-specific features, like per-route `export const config` configuration, including multi-runtime (Node.js / Edge runtimes) within the same app. ## To test this today 1. Generate a Remix + Vite project from the template: ``` npx create-remix@latest --template remix-run/remix/templates/vite ``` 1. Install `@vercel/remix`: ``` npm i --save-dev @vercel/remix ``` 1. **(Before Remix v2.8.0 is released)** - Update the `@remix-run/dev` dependency to use the "pre" tag which contains [a bug fix](https://github.com/remix-run/remix/pull/8864): ``` npm i --save--dev @remix-run/dev@pre @remix-run/serve@pre ``` 1. Configure the `vercelPreset()` in the `vite.config.ts` file: ```diff --- a/vite.config.ts +++ b/vite.config.ts @@ -1,10 +1,11 @@ import { vitePlugin as remix } from "@remix-run/dev"; import { installGlobals } from "@remix-run/node"; import { defineConfig } from "vite"; +import { vercelPreset } from "@vercel/remix/vite"; import tsconfigPaths from "vite-tsconfig-paths"; installGlobals(); export default defineConfig({ - plugins: [remix(), tsconfigPaths()], + plugins: [remix({ presets: [vercelPreset()] }), tsconfigPaths()], }); ``` 1. Create a new Vercel Project in the dashboard, and ensure the Vercel preset is set to "Remix" in the Project Settings. The autodetection will work correctly once this PR is merged, but for now it gets incorrectly detected as "Vite" preset. * **Hint**: You can create a new empty Project by running the `vercel link` command. <img width="545" alt="Screenshot 2024-02-27 at 10 37 11" src="https://github.com/vercel/vercel/assets/71256/f46baf57-5d97-4bde-9529-c9165632cb30"> 1. Deploy to Vercel, setting the `VERCEL_CLI_VERSION` environment variable to use the changes in this PR: ``` vercel deploy -b VERCEL_CLI_VERSION=https://vercel-git-tootallnate-zero-1217-research-remix-v-next-vite.vercel.sh/tarballs/vercel.tgz ```
30 lines
969 B
JavaScript
Vendored
30 lines
969 B
JavaScript
Vendored
/**
|
|
* This script is the build configuration common to all our Builder packages.
|
|
* We bundle the output using `esbuild`, and do not publish type definitions.
|
|
*
|
|
* `@vercel/build-utils` is marked as external because it's always an implicit
|
|
* dependency when the Builder is invoked by `vercel build`.
|
|
*/
|
|
import { join } from 'node:path';
|
|
import { readFileSync } from 'node:fs';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { esbuild } from './build.mjs';
|
|
|
|
export async function buildBuilder(opts, cwd = process.cwd()) {
|
|
const pkgPath = join(cwd, 'package.json');
|
|
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
const externals = Object.keys(pkg.dependencies || {});
|
|
|
|
await esbuild({
|
|
bundle: true,
|
|
external: ['@vercel/build-utils', ...externals],
|
|
...opts,
|
|
});
|
|
}
|
|
|
|
// If the script is invoked directly, do the
|
|
// common case of esbuild + tsc for types
|
|
if (fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
await buildBuilder();
|
|
}
|