@@ -196,7 +196,7 @@ HTML 文件位于 Vite 项目的[最前端和中心](/guide/#index-html-and-proj
196196 - 或仅当 ` property ` 属性匹配以下值时:` og:image ` ,` og:image:url ` ,` og:image:secure_url ` ,` og:audio ` ,` og:audio:secure_url ` ,` og:video ` ,或 ` og:video:secure_url `
197197
198198``` html {4-5,8-9}
199- <!doctype html>
199+ <!DOCTYPE html>
200200<html >
201201 <head >
202202 <link rel =" icon" href =" /favicon.ico" />
@@ -237,8 +237,8 @@ import { defineConfig } from 'vite'
237237export default defineConfig ({
238238 esbuild: {
239239 jsxFactory: ' h' ,
240- jsxFragment: ' Fragment' ,
241- },
240+ jsxFragment: ' Fragment'
241+ }
242242})
243243```
244244
@@ -251,8 +251,8 @@ import { defineConfig } from 'vite'
251251
252252export default defineConfig ({
253253 esbuild: {
254- jsxInject: ` import React from 'react'` ,
255- },
254+ jsxInject: ` import React from 'react'`
255+ }
256256})
257257```
258258
@@ -427,7 +427,7 @@ const modules = import.meta.glob('./dir/*.js')
427427// vite 生成的代码
428428const modules = {
429429 ' ./dir/bar.js ' : () => import (' ./dir/bar.js' ),
430- ' ./dir/foo.js ' : () => import (' ./dir/foo.js' ),
430+ ' ./dir/foo.js ' : () => import (' ./dir/foo.js' )
431431}
432432```
433433
@@ -457,7 +457,7 @@ import * as __vite_glob_0_0 from './dir/bar.js'
457457import * as __vite_glob_0_1 from ' ./dir/foo.js'
458458const modules = {
459459 ' ./dir/bar.js' : __vite_glob_0_0,
460- ' ./dir/foo.js' : __vite_glob_0_1,
460+ ' ./dir/foo.js' : __vite_glob_0_1
461461}
462462```
463463
@@ -484,7 +484,7 @@ const modules = import.meta.glob(['./dir/*.js', '!**/bar.js'])
484484``` js
485485// vite 生成的代码
486486const modules = {
487- ' ./dir/foo.js ' : () => import (' ./dir/foo.js' ),
487+ ' ./dir/foo.js ' : () => import (' ./dir/foo.js' )
488488}
489489```
490490
@@ -502,7 +502,7 @@ const modules = import.meta.glob('./dir/*.js', { import: 'setup' })
502502// vite 生成的代码
503503const modules = {
504504 ' ./dir/bar.js' : () => import (' ./dir/bar.js' ).then ((m ) => m .setup ),
505- ' ./dir/foo.js' : () => import (' ./dir/foo.js' ).then ((m ) => m .setup ),
505+ ' ./dir/foo.js' : () => import (' ./dir/foo.js' ).then ((m ) => m .setup )
506506}
507507```
508508
@@ -513,7 +513,7 @@ import 'vite/client'
513513// ---cut---
514514const modules = import .meta .glob (' ./dir/*.js' , {
515515 import: ' setup' ,
516- eager: true ,
516+ eager: true
517517})
518518```
519519
@@ -523,7 +523,7 @@ import { setup as __vite_glob_0_0 } from './dir/bar.js'
523523import { setup as __vite_glob_0_1 } from ' ./dir/foo.js'
524524const modules = {
525525 ' ./dir/bar.js' : __vite_glob_0_0 ,
526- ' ./dir/foo.js' : __vite_glob_0_1 ,
526+ ' ./dir/foo.js' : __vite_glob_0_1
527527}
528528```
529529
@@ -534,7 +534,7 @@ import 'vite/client'
534534// ---cut---
535535const modules = import .meta .glob (' ./dir/*.js' , {
536536 import: ' default' ,
537- eager: true ,
537+ eager: true
538538})
539539```
540540
@@ -544,7 +544,7 @@ import { default as __vite_glob_0_0 } from './dir/bar.js'
544544import { default as __vite_glob_0_1 } from ' ./dir/foo.js'
545545const modules = {
546546 ' ./dir/bar.js' : __vite_glob_0_0 ,
547- ' ./dir/foo.js' : __vite_glob_0_1 ,
547+ ' ./dir/foo.js' : __vite_glob_0_1
548548}
549549```
550550
@@ -557,23 +557,23 @@ import 'vite/client'
557557// ---cut---
558558const moduleStrings = import .meta .glob (' ./dir/*.svg' , {
559559 query: ' ?raw' ,
560- import: ' default' ,
560+ import: ' default'
561561})
562562const moduleUrls = import .meta .glob (' ./dir/*.svg' , {
563563 query: ' ?url' ,
564- import: ' default' ,
564+ import: ' default'
565565})
566566```
567567
568568``` ts
569569// vite 生成的代码
570570const moduleStrings = {
571571 ' ./dir/bar.svg' : () => import (' ./dir/bar.svg?raw' ).then ((m ) => m [' default' ]),
572- ' ./dir/foo.svg' : () => import (' ./dir/foo.svg?raw' ).then ((m ) => m [' default' ]),
572+ ' ./dir/foo.svg' : () => import (' ./dir/foo.svg?raw' ).then ((m ) => m [' default' ])
573573}
574574const moduleUrls = {
575575 ' ./dir/bar.svg' : () => import (' ./dir/bar.svg?url' ).then ((m ) => m [' default' ]),
576- ' ./dir/foo.svg' : () => import (' ./dir/foo.svg?url' ).then ((m ) => m [' default' ]),
576+ ' ./dir/foo.svg' : () => import (' ./dir/foo.svg?url' ).then ((m ) => m [' default' ])
577577}
578578```
579579
@@ -583,7 +583,7 @@ const moduleUrls = {
583583import ' vite/client'
584584// ---cut---
585585const modules = import .meta .glob (' ./dir/*.js' , {
586- query: { foo: ' bar' , bar: true },
586+ query: { foo: ' bar' , bar: true }
587587})
588588```
589589
@@ -595,15 +595,15 @@ const modules = import.meta.glob('./dir/*.js', {
595595import ' vite/client'
596596// ---cut---
597597const modulesWithBase = import .meta .glob (' ./**/*.js' , {
598- base: ' ./base' ,
598+ base: ' ./base'
599599})
600600```
601601
602602``` ts
603603// code produced by vite:
604604const modulesWithBase = {
605605 ' ./dir/foo.js' : () => import (' ./base/dir/foo.js' ),
606- ' ./dir/bar.js' : () => import (' ./base/dir/bar.js' ),
606+ ' ./dir/bar.js' : () => import (' ./base/dir/bar.js' )
607607}
608608```
609609
@@ -619,7 +619,7 @@ const modulesWithBase = {
619619
620620- 这只是一个 Vite 独有的功能而不是一个 Web 或 ES 标准
621621- 该 Glob 模式会被当成导入标识符:必须是相对路径(以 ` ./ ` 开头)或绝对路径(以 ` / ` 开头,相对于项目根目录解析)或一个别名路径(请看 [ ` resolve.alias ` 选项] ( /config/shared-options.md#resolve-alias ) )。
622- - Glob 匹配是使用 [ ` tinyglobby ` ] ( https://github.com/SuperchupuDev/tinyglobby ) 来实现的 —— 阅读它的文档来查阅 [ 支持的 Glob 模式] ( https://github.com/mrmlnc/fast-glob#pattern-syntax ) 。
622+ - Glob 匹配是使用 [ ` tinyglobby ` ] ( https://github.com/SuperchupuDev/tinyglobby ) 来实现的 —— 阅读它的文档来查阅 [ 支持的 Glob 模式] ( https://superchupu.dev/tinyglobby/comparison ) 。
623623- 你还需注意,所有 ` import.meta.glob ` 的参数都必须以字面量传入。你 ** 不** 可以在其中使用变量或表达式。
624624
625625## 动态导入 {#dynamic-import}
@@ -657,8 +657,8 @@ init({
657657 imports: {
658658 someFunc : () => {
659659 /* ... */
660- },
661- },
660+ }
661+ }
662662}).then (() => {
663663 /* ... */
664664})
@@ -682,8 +682,9 @@ import wasmUrl from 'foo.wasm?url'
682682
683683const main = async () => {
684684 const responsePromise = fetch (wasmUrl)
685- const { module , instance } =
686- await WebAssembly .instantiateStreaming (responsePromise)
685+ const { module , instance } = await WebAssembly .instantiateStreaming (
686+ responsePromise
687+ )
687688 /* ... */
688689}
689690
@@ -729,7 +730,7 @@ worker 构造函数会接受可以用来创建 “模块” worker 的选项:
729730
730731``` ts
731732const worker = new Worker (new URL (' ./worker.js' , import .meta .url ), {
732- type: ' module' ,
733+ type: ' module'
733734})
734735```
735736
0 commit comments