Vite 介绍

1.11

Vite: Next generation fronteend tooling. It's fast!

新一代的前端开发打包工具,启动和热更新速度都很快(秒级)。支持 Vue,React,Svelte 等前端框架

最新版本(v5.0) 需要 Node 18+, 20+

New project

npm create vite@latest

Migrate from Webpack to Vite

  • npm i vite --save-dev

  • package.json

    "scripts": {
      "dev": "vite",
    }
    
  • Copy public/index.html to ./index.html

  • index.html, replace %PUBLIC_URL%/ with /, add

    <script type="module" src="/src/index.js"></script>
    
  • npm run dev

📖