From 6ad6734ae269cedd08203320d7f914337c67c868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Tue, 9 Aug 2022 13:07:45 +0800 Subject: [PATCH] docs: fix renderBuiltUrl example (#9558) --- docs/guide/build.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guide/build.md b/docs/guide/build.md index bcc840d40cb56a..30dadbbb2473df 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -210,7 +210,7 @@ A single static [base](#public-base-path) isn't enough in these scenarios. Vite ```ts experimental: { - renderBuiltUrl: (filename: string, { hostType: 'js' | 'css' | 'html' }) => { + renderBuiltUrl(filename: string, { hostType }: { hostType: 'js' | 'css' | 'html' }) { if (hostType === 'js') { return { runtime: `window.__toCdnUrl(${JSON.stringify(filename)})` } } else { @@ -224,11 +224,11 @@ If the hashed assets and public files aren't deployed together, options for each ```ts experimental: { - renderBuiltUrl(filename: string, { hostType: 'js' | 'css' | 'html', type: 'public' | 'asset' }) { + renderBuiltUrl(filename: string, { hostId, hostType, type }: { hostId: string, hostType: 'js' | 'css' | 'html', type: 'public' | 'asset' }) { if (type === 'public') { return 'https://www.domain.com/' + filename } - else if (path.extname(importer) === '.js') { + else if (path.extname(hostId) === '.js') { return { runtime: `window.__assetsPath(${JSON.stringify(filename)})` } } else {