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

Vite #139

Open
coryhouse opened this issue Jul 16, 2022 · 1 comment
Open

Vite #139

coryhouse opened this issue Jul 16, 2022 · 1 comment

Comments

@coryhouse
Copy link
Owner

coryhouse commented Jul 16, 2022

Vite benefits over create-react-app

  1. Faster startup. (Uses esbuild with rollup instead of webpack. Uses separate TypeScript project for Vite config to speed builds too.
  2. Scales better. Dynamically passes native ESM to the browser for speed. Code is "lazy" processed the moment it's needed to display the screen. (create-react-app compiles the output on each save first). (See type="module" in index.html).
  3. Prebundles dependencies via esbuild (written in Go so it's fast)
  4. Consistently faster HMR (even for huge projects) since it's handled over ESM
  5. Supports glob imports
  6. Automatically preloads chunks
  7. Easily generate a reusable component library via library mode
  8. Supports SSR via a plugin or libraries
  9. The CLI prompts for choices.
  10. Works for other frameworks like Vue, Svelte, etc too.

Notable differences from create-react-app

  1. Create via npm init vite
  2. main.tsx is the entry point instead of index.tsx
  3. index.html is in root instead of /public
  4. No testing built in, but Vitest is easy to add
  5. Targets modern browsers by default
  6. Env vars are under import.meta.env instead

More goodies in awesome-vite

Other tips

Speed up e2e tests calling Vite

@donjosemathew
Copy link

Vite benefits over create-react-app

  1. Faster startup. (Uses esbuild with rollup instead of webpack. Uses separate TypeScript project for Vite config to speed builds too.
  2. Scales better. Dynamically passes native ESM to the browser for speed. Code is "lazy" processed the moment it's needed to display the screen. (create-react-app compiles the output on each save first). (See type="module" in index.html).
  3. Prebundles dependencies via esbuild (written in Go so it's fast)
  4. Consistently faster HMR (even for huge projects) since it's handled over ESM
  5. Supports glob imports
  6. Automatically preloads chunks
  7. Easily generate a reusable component library via library mode
  8. Supports SSR via a plugin or libraries
  9. The CLI prompts for choices.
  10. Works for other frameworks like Vue, Svelte, etc too.

Notable differences from create-react-app

  1. Create via npm init vite
  2. main.tsx is the entry point instead of index.tsx
  3. index.html is in root instead of /public
  4. No testing built in, but Vitest is easy to add
  5. Targets modern browsers by default
  6. Env vars are under import.meta.env instead

More goodies in awesome-vite

Other tips

Speed up e2e tests calling Vite

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

No branches or pull requests

2 participants