惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
雷峰网
雷峰网
罗磊的独立博客
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
博客园 - 司徒正美
Last Week in AI
Last Week in AI
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
量子位
宝玉的分享
宝玉的分享

Netlify Developers

AI model comparison using Netlify's AI Gateway | Netlify Developers Build an AI agent to automatically process and summarize form submissions | Netlify Developers Build an AI agent to automatically generate relevant images for blog posts | Netlify Developers Prerendering SPA content pages to enable AI agent access | Netlify Developers Identify image optimization opportunities with Netlify Observability | Netlify Developers Fix top 404 page not found errors with Netlify Observability | Netlify Developers Introducing AI Gateway: built-in AI model access on Netlify | Netlify Developers Introducing Observability: your project insights on Netlify | Netlify Developers From first publish to first update with AI agents | Netlify Developers How to use Agent Runners on Netlify | Netlify Developers Add forms to your project with AI + Netlify | Netlify Developers Track Real User Metrics | Netlify Developers Lighthouse performance scores on Netlify | Netlify Developers Review your AI project before you ship | Netlify Developers Using environment variables in AI Projects on Netlify | Netlify Developers Build prototypes and MVPs fast with AI + Netlify | Netlify Developers Pause auto-publishing on Netlify | Netlify Developers Run serverless functions, storage, and more natively in Nuxt dev | Netlify Developers Netlify Office Hours: The AX Arcade challenge | Netlify Developers Netlify Office Hours: Prompting with style | Netlify Developers Netlify Office Hours: RAG Apps with OpenAI + Netlify DB | Netlify Developers How to build a RAG application with Neon, Netlify & OpenAI | Netlify Developers Netlify Office Hours: Netlify DB (powered by Neon) | Netlify Developers Netlify Office Hours: Netlify MCP Server | Netlify Developers Netlify Office Hours: Netlify Vite Plugin | Netlify Developers Building MCPs with Netlify | Netlify Developers Deploying sites from your AI tool | Netlify Developers Adding your domain using Netlify API | Netlify Developers Build a context driven chat bot with Netlify Blob and OpenAI | Netlify Developers Simplify deployments with Netlify’s branch-matching environment variables | Netlify Developers
How to deploy Remix Vite to Netlify | Netlify Developers
2024-02-23 · via Netlify Developers

#TL;DR

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.

#Why Vite?

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.

A note on legacy support

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.

#Come on in, the water’s lovely!

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.

#Migrating an existing Remix site to Vite

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 Functions

  1. First, follow the migration steps in the Remix docs , including updating versions and installing Vite.
  2. Upgrade @netlify/remix-adapter
  3. Replace your remix.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()],

});

  1. Delete server.ts and app/entry.server.tsx from your site
  2. Change your package.json scripts to match these:

{

"build": "remix vite:build",

"dev": "remix vite:dev",

"start": "netlify serve"

}

  1. Change your netlify.toml to match this:

[build]

command = "npm run build"

publish = "build/client"

[dev]

command = "npm run dev"

framework = "vite"

#Netlify Edge Functions

  1. First, follow the migration steps in the Remix docs , including updating versions and installing Vite.
  2. Upgrade @netlify/remix-edge-adapter and @netlify/remix-runtime
  3. Replace your remix.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()],

});

  1. Delete server.ts from your site
  2. Replace your app/server.entry.tsx with this:

// @ts-expect-error virtual module

// eslint-disable-next-line import/no-unresolved

export { default } from "virtual:netlify-server-entry";

  1. Change your package.json scripts to match these:

{

"build": "remix vite:build",

"dev": "remix vite:dev",

"start": "netlify serve"

}

  1. Change your netlify.toml to match this:

[build]

command = "npm run build"

publish = "build/client"

[dev]

command = "npm run dev"

framework = "vite"

Happy Remixing!

#More resources

For more information on building with the technologies in this article: