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

推荐订阅源

Webroot Blog
Webroot Blog
T
Troy Hunt's Blog
S
Security Affairs
Hacker News: Ask HN
Hacker News: Ask HN
Attack and Defense Labs
Attack and Defense Labs
P
Proofpoint News Feed
大猫的无限游戏
大猫的无限游戏
G
Google Developers Blog
WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
N
Netflix TechBlog - Medium
博客园_首页
Recorded Future
Recorded Future
罗磊的独立博客
I
InfoQ
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
雷峰网
雷峰网
博客园 - Franky
Project Zero
Project Zero
T
Tailwind CSS Blog
Microsoft Azure Blog
Microsoft Azure Blog
V2EX - 技术
V2EX - 技术
MyScale Blog
MyScale Blog
C
Check Point Blog
博客园 - 【当耐特】
D
Docker
aimingoo的专栏
aimingoo的专栏
宝玉的分享
宝玉的分享
小众软件
小众软件
Microsoft Security Blog
Microsoft Security Blog
P
Privacy & Cybersecurity Law Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
Jina AI
Jina AI
N
News | PayPal Newsroom
Cisco Talos Blog
Cisco Talos Blog
L
Lohrmann on Cybersecurity
T
Tenable Blog
Forbes - Security
Forbes - Security
V
Vulnerabilities – Threatpost
阮一峰的网络日志
阮一峰的网络日志
H
Heimdal Security Blog
Google Online Security Blog
Google Online Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
量子位
I
Intezer
H
Hacker News: Front Page
博客园 - 司徒正美
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

StackBlitz Blog

Cloudflare is now backing pkg.pr.new’s data infrastructure! Bolt 100K Open Source Fund ViteConf 2024 was a blast Unbundling the JavaScript ecosystem StackBlitz is joining the Open Source Pledge Announcing TutorialKit: Interactive tutorials in the browser Get ready for ViteConf 2024 Announcing pkg.pr.new StackBlitz welcomes Ari Perkkiö, core team member of Vitest Catch us at Figma Config WebContainers and the future of web dev (interview with Jòan Varvenne) Open Source at StackBlitz Avoiding CORS issues with this one simple trick How to document design system components Improving the developer experience of enterprise design systems Flow state: Why fragmented thinking is worse than any interruption What is Storybook? An Overview for Developers The Self-Rendering Eval Shirt Starters Upgrade: WebContainers and Vite Putting the Dev in Figma’s Dev Mode Announcing StackBlitz Self-hosted Building Together in Illinois 5 lessons design systems teams can learn from open-source maintainers Announcing Native Language Support in WebContainers Introducing StackBlitz Teams ViteConf is back! Bringing Sharp to WebAssembly and WebContainers npm, yarn and pnpm are now supported natively in WebContainers The Atomic Waltz: Unraveling WebAssembly Issues in V8 and SpiderMonkey WebContainers now run on Safari, iOS, and iPadOS Now I am become the Destroyer of Threads WebContainer API is here. StackBlitz September 2022 Update StackBlitz August 2022 Update StackBlitz July 2022 Update Introducing: Collections and Social Previews! Down the caching-hole: adventures in Announcing ViteConf StackBlitz June 2022 Update The Fox and the Bolt: Bringing WebContainers to Firefox WebContainers are now supported in Firefox on desktop and Android StackBlitz May 2022 Update StackBlitz April 2022 Update Cloudflare and StackBlitz partner to bring Cloudflare Workers to your browser Powering over 2M developers a month, StackBlitz has raised $7.9M StackBlitz March 2022 Update Announcement: WebContainers are out of beta in Chromium StackBlitz has joined the Bytecode Alliance StackBlitz February 2022 Update Bringing WebContainers to all Browsers: a call to action for COEP Credentialless Cross-Browser support with Cross-Origin isolation StackBlitz welcomes Patak, core maintainer of Vite Chasing Memory Bugs through V8 and WebAssembly Remix v1 has landed, and it runs on WebContainers SvelteKit is now fully supported in WebContainers We Shopify partners with StackBlitz to bring Hydrogen development in-browser StackBlitz September 2021 Update Introducing Vite.new Templates! Announcing WebContainers Astro support! 🛰 Introducing: SQLite3 support in WebContainers! 🧪 StackBlitz July 2021 Update StackBlitz June 2021 Update Introducing WebContainers: Run Node.js natively in your browser Interactive Docs: The new norm for Remote Work
What is Vite (and why is it so popular)?
Eric Simons CEO at StackBlitz making web development fast & secu · 2024-04-29 · via StackBlitz Blog

In the web development world, it’s hard to go more than a few days without hearing about Vite.

Its popularity has skyrocketed since its release in April 2020. At the time of writing this post, the project has blown past 64k stars on GitHub and over 12 million weekly downloads and now powers most open-source frameworks like Nuxt, SvelteKit, Astro, SolidStart and Remix (just to name a few).

Vite downloads

At StackBlitz, we’re not shy about how much we love Vite. We’ve been supporting Vite since its beginnings in 2021. We’re proud to count patak, a Vite core maintainer, as part of our team, and we’re hosting ViteConf, a conference that showcases its vibrant ecosystem.

If you’d like to learn about Vite’s history, we recommend you watch the ViteConf 2022 Keynote by Evan You.

Even with all the buzz, we recognize that many developers may still be unfamiliar with what Vite is, or the crucial role it plays in fueling the development of modern web frameworks and tools.

In this post, we’ll give you a primer on Vite and how, after just a few years, it has grown to power a huge portion of the modern web.

What is Vite?

Pronounced /vit/, Vite is French for “quickly” or “fast” and let’s just say Vite lives up to its name.

In a nutshell, Vite is a modern JavaScript build tool that provides out-of-the-box support for common web patterns, offering optimized builds with the flexibility and maturity of rollup paired with a snappy bundleless dev server made possible by esbuild and native ES modules.

Vite was conceived by Evan You, creator of Vue.js, to simplify the bundling process by reducing the bottlenecks devs experience when starting up development servers and processing reloads after file edits.

Vite core features

The first difference you’ll notice when you run Vite is that the dev server starts instantly. You can fire up vite.new and see it in action. This is because Vite embraces an on-demand approach to serve your application to the browser. Instead of first bundling the entire source code, Vite reacts to browser requests transforming your authored modules on the fly to native ESM modules that the browser can understand. Vite provides out-of-the-box support for TypeScript, PostCSS, CSS preprocessors, JSON, WASM, and more, and can be extended to support all your favourite frameworks and tools through an ever-growing ecosystem of plugins.

Each time you change any file within your project during dev, Vite uses the module graph of your application to only hot reload the affected modules (HMR). This allows developers to preview their changes and their effects on the application. Vite HMR is so fast that it is possible to let the editor autosave getting a feedback loop akin to the one you get when modifying CSS in the browser dev tools.

Vite also performs dependency pre-bundling. During development, it uses esbuild to bundle your dependencies and caches them to speed up future server startup. This optimization step also helps speed up loading times for dependencies that export many small modules (like lodash), as the browser loads only a few chunks per dependency instead. It also allows Vite to support CommonJS and UMD code in dependencies, as they are bundled into native ESM modules.

When you are ready to deploy, Vite will build your application using an optimized Rollup setup. It performs CSS code splitting, adds preload directives, and optimizes the loading of async chunks without any configuration. Vite offers a universal rollup-compatible plugin API that works for both development and production, making it easier to extend and customize your build process.

Benefits of using Vite

There are several key benefits to using Vite. Here are a few of our favorites:

Open source and independent

Vite is developed by a community of open-source developers, spearheaded by a team of developers from different backgrounds. The Vite core repo has recently crossed 900 contributors. It’s actively developed and maintained, with new features implemented and bugs resolved steadily. It also means the evolving feature set reflects a cross-section of real-world application needs across a large number of diverse products.

Fast local development

DX is at the heart of Vite, and you can feel it every time you hit save. We often take reload speeds for granted. But as your application grows, and reload speeds grind to a halt, you’ll be thankful for Vite’s ability to maintain (almost) instant reloads regardless of application size.

Broad ecosystem support

The Vite approach has been very well received, and most frameworks and tools use Vite by default or have first-class support. By opting to use Vite as a build tool, maintainers of these projects can share a common base between them and improve it together over time. So they can spend more time developing features their users need and less time reinventing the wheel.

That’s a win for everyone.

Easily extensible

Vite’s bet on Rollup’s plugin API has paid off. Plugins allow downstream projects to share features above what Vite core provides. There are so many high-quality plugins ready to use, such us vite-plugin-pwa and vite-imagetools.

A big piece in the framework-building puzzle

Vite is one of the big pieces that modern meta-frameworks are building on top of. It is part of a bigger ecosystem of tools that are taking a similar path. Volar is another tool we at StackBlitz are proud to be supporting. It provides the tools needed to build a solid and performant editing experience in code editors for custom programming languages like Vue, MDX, and Astro. It allows frameworks to offer features like hover information, diagnostics, and auto-completions to its users, sharing Volar as a common base to power them. Another great example is Nitro, a server toolkit to create full-featured web servers that support every major deployment platform out of the box. It is part of a fantastic collection of framework-agnostic libraries called UnJS. There is also Dev Toolkit, a new effort to share a common base for framework dev tools.

Getting started with Vite

For tools like StackBlitz and Vite, the best way to understand why they are different is to try them out. Vite is fully supported in StackBlitz, which makes it easy to spin up on-demand environments. The Vite team uses StackBlitz to power its online starters. Click on your favourite framework and edit some components to see Vite in action.

VueSvelteReactPreactLitSolidQwik

Developing with Vite

There are three commands you can run while developing with Vite.

  • vite dev starts the Vite development server (automatically started for you when you open a Vite project in StackBlitz)
  • vite build prepares a production build
  • vite preview allows you to preview your built site or application

Be sure to run vite build before running vite preview to see your changes.

Vite’s future

In his most recent ViteConf keynote, Evan shared that, while Vite is making great progress, there are some known issues and challenges the project faces.

As we discussed before, Vite currently uses Rollup for production builds. That’s not as fast as native bundlers like esbuild or Bun. Vite also minimizes inconsistencies between development and production environments as much as possible, but some are unavoidable given the differences between both Rollup and esbuild.

Evan is now leading a new team to develop Rolldown, a rust-based port of Rollup with a best effort on compatibility built on top of OXC (The JavaScript Oxidation Compiler). The idea is to replace both Rollup and esbuild in Vite with Rolldown. Vite will have a single foundation with the flexibility of Rollup with the speed of esbuild, removing inconsistencies, making the code base more maintainable, and speeding up build times.

Rolldown is in early stages, but it is already showing promising results. The project is now open source, and the Rolldown team is looking for contributors to help make this vision a reality. If you are interested in build tools and Rust, join the effort in the Rolldown GitHub repository and the Rolldown Discord community.

In parallel, the Vite team keeps improving Vite with each release. The work started by upstreaming vite-node (the engine that powers Vitest and Nuxt Dev SSR), has evolved into a full revision of Vite’s API for framework authors. The new Environment API is slated to be released in Vite v6, and it is poised to be one of the biggest changes in Vite since the release of Vite 2. It will allow to run code through the Vite plugins pipeline in any number of environments, unlocking first-class support for workerd, RSC, and more.

Start your first Vite project today

Vite is forging a path forward and is fast becoming the de facto build tool for the JavaScript ecosystem.

StackBlitz is proud to be a Vite supporter and we look forward to seeing how the project progresses in 2024!

Give https://vite.new a try today and stay tuned for more exciting Vite-related news.