当前位置:网站首页>尤雨溪向初学者推荐Vite 【为什么使用Vite】
尤雨溪向初学者推荐Vite 【为什么使用Vite】
2022-07-26 11:51:00 【InfoQ】
问题
服务器启动缓慢
- 依赖关系大多是普通的JavaScript,在开发过程中不经常更改。一些大型依赖项(例如,具有数百个模块的组件库)的处理成本也非常高。依赖项也可以以各种模块格式提供(例如ESM或CommonJS)。
- Vite 使用esbuild[预捆绑依赖项]。esbuild是用Go编写的,预捆绑依赖项比基于JavaScript的捆绑器快10-100倍。
- 源代码通常包含需要转换的非纯JavaScript(例如JSX,CSS或Vue / Svelte组件),并且将经常编辑。此外,并非所有源代码都需要同时加载(例如,使用基于路由的代码拆分)。
- Vite 通过本机 ESM提供源代码。这实质上是让浏览器接管了捆绑器的部分工作:Vite只需要在浏览器请求时按需转换和提供源代码。只有在当前屏幕上实际使用时,才会处理条件动态导入背后的代码。
更新缓慢
304 Not Modified``Cache-Control: max-age=31536000,immutable为什么要捆绑生产
为什么不与esbuild捆绑在一起?
esbuild``esbuildVite与X有何不同?
WMR
@web/开发服务器
es-dev-server@web/dev-server@webSnowpack
安装)的开始
概述
/vit/- 一种开发服务器,它提供比本机 ES 模块[更丰富的功能增强],例如极快的热模块更换 (HMR)。
- 一种生成命令,用于将代码与汇总捆绑在一起,该命令已预先配置为输出用于生产的高度优化的静态资产。
浏览器支持
。元尝试在线体验维特
vite.new/{template}搭建您的第一个 Vite 项目
$ npm create [email protected]
$ yarn create vite
$ pnpm create vite
# npm 6.x
npm create [email protected] my-vue-app --template vue
# npm 7+, extra double-dash is needed:
npm create [email protected] my-vue-app -- --template vue
# yarn
yarn create vite my-vue-app --template vue
# pnpm
pnpm create vite my-vue-app --template vue
vanilla``vanilla-ts``vue``vue-ts``react``react-ts``preact``preact-ts``lit``lit-ts``svelte``svelte-ts社区模板
npx degit user/project my-project
cd my-project
npm install
npm run dev
main``#mainnpx degit user/project#main my-project
index.html
和project root
index.html``public``index.htmlindex.html``<script type="module" src="...">``<script type="module">``<link href>``index.html``%PUBLIC_URL%<root>.html指定备用根目录
vite``vite serve some/sub/dir命令行界面
vite``npx vite{
"scripts": {
"dev": "vite", // start dev server, aliases: `vite dev`, `vite serve`
"build": "vite build", // build for production
"preview": "vite preview" // locally preview production build
}
}
--port``--https``npx vite --help使用未释放的提交
git clone https://github.com/vitejs/vite.git
cd vite
pnpm install
cd packages/vite
pnpm run build
pnpm link --global # you can use your preferred package manager for this step
pnpm link --global vite``vite边栏推荐
- 7月27日19:30直播预告:HarmonyOS3及华为全场景新品发布会
- 物联网设备加密的意义
- Why BGP server is used in sunflower remote control? Automatic optimal route and high-speed transmission across operators
- pytest接口自动化测试框架 | pytest常用插件
- Preliminary test yolov7
- 沟通中经常用到的几个库存术语
- Esp8266 Arduino programming example - development environment construction (based on platformio)
- Marriage seeking story
- Metauniverse gamefi chain game system development NFT Technology
- System call capture and analysis - modify kernel methods to add system calls
猜你喜欢

Miccai2022 paper | evolutionary multi-objective architecture search framework: application in covid-19 3D CT classification

3.2 create menu and game pages (Part 2)

系统调用捕获和分—Ring3层LD_PRELOAD机制进行库函数劫持

Pycharm is really strong

An online duplicate of a hidden bug

什么是Per-Title编码?

Marriage seeking story

Hou Peixin, chairman of the openharmony Working Committee of the open atom open source foundation, sent a message to the openatom openharmony sub forum

Ga-rpn: recommended area network for guiding anchors

SSJ-21B时间继电器
随机推荐
了解string类
最新心形拼图小程序源码+带流量主
What is per title encoding?
Understand the string class
音视频+
pytest接口自动化测试框架 | pytest获取执行数据、pytest禁用插件
常用的 list.isEmpty() 为何突然报null?
C language code quantity statistical tool
一些实用、常用、效率越来越高的 Kubernetes 别名
【附下载】一款强大的Web自动化漏洞扫描工具——Xray
Why BGP server is used in sunflower remote control? Automatic optimal route and high-speed transmission across operators
基于 Flink CDC 实现海量数据的实时同步和转换
Understanding useref is enough
系统调用捕获和分析—修改内核方法添加系统调用
c语言代码量统计工具
flink 写redis 比较慢,大家有啥思路优化吗?
Metauniverse gamefi chain game system development NFT Technology
pytest接口自动化测试框架 | 使用装饰器修饰需要运行的用例
Talking about web vitals
V01 - XX,记录美好生活从日志开始