














Remix v2.7.0 now has stable support for Vite, with a faster and more reliable development experience, and we’re excited to announce that this is now fully supported on Netlify. Our new Vite-based Remix adapters and templates are available today for both Netlify Functions and Edge Functions.
Vite is the leading build and development tool for web frameworks, and is well loved for its excellent developer experience, speedy performance, and the huge ecosystem of plugins. There’s a reason that almost all modern web frameworks now use it.
In October 2023, the Remix team announced that they were joining this growing community, previewing unstable support in Remix v2.2.0. After several months of furious development, the team has released stable support for Vite in Remix v2.7.0. It is now the recommended way to build all Remix sites.
The legacy bundler is still supported, but is likely to be removed in Remix 3.
Netlify will continue to support sites using the legacy bundler, but the Netlify templates will now generate Vite sites.
For all these reasons and more, it’s a great time to start moving your site to use Vite. Here’s how to get started.
To create a new Remix Vite site on Netlify, you just need to run one command:
npx create-remix@latest --template netlify/remix-template
You can then choose whether you would like to deploy to Netlify Functions (Node-based, deployed to one region) or Netlify Edge Functions (Deno-based, deployed to a global edge network). Your site is then ready to deploy to Netlify.
If you have an existing Remix site on Netlify, there are a few steps needed if you want to migrate. The project structure for Netlify Functions and Netlify Edge Functions are now almost identical, but the steps to upgrade are slightly different.
@netlify/remix-adapterremix.config.js with this vite.config.ts:import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { netlifyPlugin } from "@netlify/remix-adapter/plugin";
export default defineConfig({
plugins: [remix(), netlifyPlugin(), tsconfigPaths()],
});
server.ts and app/entry.server.tsx from your sitepackage.json scripts to match these:{
"build": "remix vite:build",
"dev": "remix vite:dev",
"start": "netlify serve"
}
netlify.toml to match this:[build]
command = "npm run build"
publish = "build/client"
[dev]
command = "npm run dev"
framework = "vite"
@netlify/remix-edge-adapter and @netlify/remix-runtimeremix.config.js with this vite.config.ts:import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { netlifyPlugin } from "@netlify/remix-edge-adapter/plugin";
export default defineConfig({
plugins: [remix(), netlifyPlugin(), tsconfigPaths()],
});
server.ts from your siteapp/server.entry.tsx with this:// @ts-expect-error virtual module
// eslint-disable-next-line import/no-unresolved
export { default } from "virtual:netlify-server-entry";
package.json scripts to match these:{
"build": "remix vite:build",
"dev": "remix vite:dev",
"start": "netlify serve"
}
netlify.toml to match this:[build]
command = "npm run build"
publish = "build/client"
[dev]
command = "npm run dev"
framework = "vite"
Happy Remixing!
For more information on building with the technologies in this article:
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。