Skip to content

Commit

Permalink
Merge pull request #947 from vitejs/sync-ebfa5935-1
Browse files Browse the repository at this point in the history
docs(en): merge docs-cn/sync-docs into docs-cn/dev @ ebfa593
  • Loading branch information
ShenQingchuan authored Apr 26, 2024
2 parents 0121db1 + 3fb1a51 commit a0215dc
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 164 deletions.
36 changes: 11 additions & 25 deletions .vitepress/theme/components/AsideSponsors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,18 @@ const sponsors = computed(() => {
</script>

<template>
<a
class="viteconf"
href="https://viteconf.org/23/replay?utm=vite-sidebar"
target="_blank"
>
<img width="22" height="22" src="/viteconf.svg" />
<a class="vite-event" href="https://lu.ma/vite" target="_blank">
<img width="22" height="22" src="/logo.svg" />
<span>
<p class="extra-info">Beyond Fast</p>
<p class="heading">ViteConf 2023</p>
<p class="extra-info">Watch the replay!</p>
<p class="extra-info">May 9th, 2024</p>
<p class="heading">Vite Meetup SF</p>
</span>
</a>
<VPDocAsideSponsors v-if="data" :data="sponsors" />
</template>

<style>
.viteconf {
.vite-event {
margin-top: 1rem;
margin-bottom: 1rem;
border-radius: 14px;
Expand All @@ -53,35 +48,26 @@ const sponsors = computed(() => {
border: 2px solid var(--vp-c-bg-alt);
transition: border-color 0.5s;
}
.viteconf:hover {
.vite-event:hover {
border: 2px solid var(--vp-c-brand-light);
}
.viteconf img {
.vite-event img {
transition: transform 0.5s;
transform: scale(1.25);
}
.viteconf:hover img {
.vite-event:hover img {
transform: scale(1.75);
}
.viteconf .heading {
background-image: linear-gradient(
120deg,
#b047ff 16%,
var(--vp-c-brand-lighter),
var(--vp-c-brand-lighter)
);
.vite-event .heading {
background-image: var(--vp-home-hero-name-background);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.viteconf .extra-info {
.vite-event .extra-info {
color: var(--vp-c-text-1);
opacity: 0;
font-size: 0.7rem;
padding-left: 0.1rem;
transition: opacity 0.5s;
}
.viteconf:hover .extra-info {
opacity: 0.9;
}
</style>
26 changes: 14 additions & 12 deletions guide/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,24 +257,26 @@ experimental: {

如果 hash 后的资源和公共文件没有被部署在一起,可以根据该函数的第二个参数 `context` 上的字段 `type` 分别定义各个资源组的选项:

<!-- prettier-ignore-start -->
```ts twoslash
import type { UserConfig } from 'vite'
import path from 'node:path'
const config: UserConfig = {
// ---cut-before---
experimental: {
renderBuiltUrl(filename, { hostId, hostType, type }) {
if (type === 'public') {
return 'https://www.domain.com/' + filename
} else if (path.extname(hostId) === '.js') {
return { runtime: `window.__assetsPath(${JSON.stringify(filename)})` }
} else {
return 'https://cdn.domain.com/assets/' + filename
}
},
// ---cut-before---
experimental: {
renderBuiltUrl(filename, { hostId, hostType, type }) {
if (type === 'public') {
return 'https://www.domain.com/' + filename
} else if (path.extname(hostId) === '.js') {
return { runtime: `window.__assetsPath(${JSON.stringify(filename)})` }
} else {
return 'https://cdn.domain.com/assets/' + filename
}
},
// ---cut-after---
},
// ---cut-after---
}
```
<!-- prettier-ignore-end -->

请注意,传递的 `filename` 是一个已解码的 URL,如果函数返回了一个 URL 字符串,那么它也应该是已解码的。当 Vite 渲染 URL 时会自动处理编码。如果返回的是一个带有 `runtime` 的对象,就需要在必要的地方自行处理编码,因为运行时的代码将会按照原样呈现。
2 changes: 1 addition & 1 deletion guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ import MyWorker from './worker?worker&url'

### [`'nonce-{RANDOM}'`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/Sources#nonce-base64-value)

当设置了 [`html.cspNonce`](/config/shared-options#html-cspnonce) 时,Vite 会在输出的脚本标签和样式表的链接标签中添加一个带有指定值的 nonce 属性。请注意,Vite 不会将 nonce 属性添加到其他标签中,例如 `<style>`。此外,设置此选项时,Vite 将注入一个 meta 标签`<meta property="csp-nonce" nonce="PLACEHOLDER" />`
当设置了 [`html.cspNonce`](/config/shared-options#html-cspnonce) 时,Vite 会为任何 `<script>``<style>` 标签,以及样式表和模块预加载的 `<link>` 标签添加一个 nonce 属性。此外,当设置了这个选项时,Vite 会注入一个 meta 标签 (`<meta property="csp-nonce" nonce="PLACEHOLDER" />`)

带有 `property="csp-nonce"` 的 meta 标签的 nonce 值将在开发和构建后的必要时刻被 Vite 使用。

Expand Down
5 changes: 1 addition & 4 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ hero:
- theme: alt
text: 在 GitHub 上查看
link: https://github.com/vitejs/vite
- theme: brand
text: 🎉 ViteConf 23!
link: https://viteconf.org/23/replay?utm=vite-homepage

features:
- icon: 💡
Expand Down Expand Up @@ -53,4 +50,4 @@ import { fetchReleaseTag } from './.vitepress/utils/fetchReleaseTag.js'
onMounted(() => {
fetchReleaseTag()
})
</script>
</script>
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"vite": "^5.1.6",
"feed": "^4.2.2",
"yorkie": "^2.0.0",
"@shikijs/vitepress-twoslash": "^1.2.4",
"@shikijs/vitepress-twoslash": "^1.3.0",
"@types/express": "^4.17.21",
"vitepress": "1.0.2",
"vue": "^3.4.21"
"vitepress": "1.1.3",
"vue": "^3.4.24"
},
"scripts": {
"dev": "vitepress dev .",
Expand Down
Loading

0 comments on commit a0215dc

Please sign in to comment.