Skip to content

Commit e7adcf0

Browse files
authored
docs: twoslash cut does not take effect (#16466)
1 parent 6a127d6 commit e7adcf0

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

docs/guide/build.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -259,24 +259,26 @@ experimental: {
259259

260260
If the hashed assets and public files aren't deployed together, options for each group can be defined independently using asset `type` included in the second `context` param given to the function.
261261

262+
<!-- prettier-ignore-start -->
262263
```ts twoslash
263264
import type { UserConfig } from 'vite'
264265
import path from 'node:path'
265266
const config: UserConfig = {
266-
// ---cut-before---
267-
experimental: {
268-
renderBuiltUrl(filename, { hostId, hostType, type }) {
269-
if (type === 'public') {
270-
return 'https://www.domain.com/' + filename
271-
} else if (path.extname(hostId) === '.js') {
272-
return { runtime: `window.__assetsPath(${JSON.stringify(filename)})` }
273-
} else {
274-
return 'https://cdn.domain.com/assets/' + filename
275-
}
276-
},
267+
// ---cut-before---
268+
experimental: {
269+
renderBuiltUrl(filename, { hostId, hostType, type }) {
270+
if (type === 'public') {
271+
return 'https://www.domain.com/' + filename
272+
} else if (path.extname(hostId) === '.js') {
273+
return { runtime: `window.__assetsPath(${JSON.stringify(filename)})` }
274+
} else {
275+
return 'https://cdn.domain.com/assets/' + filename
276+
}
277277
},
278-
// ---cut-after---
278+
},
279+
// ---cut-after---
279280
}
280281
```
282+
<!-- prettier-ignore-end -->
281283

282284
Note that the `filename` passed is a decoded URL, and if the function returns a URL string, it should also be decoded. Vite will handle the encoding automatically when rendering the URLs. If an object with `runtime` is returned, encoding should be handled yourself where needed as the runtime code will be rendered as is.

0 commit comments

Comments
 (0)