Skip to content

Commit 09c4fc0

Browse files
authored
docs: warning for new URL(url, import.meta.url) (#7279)
1 parent c02537b commit 09c4fc0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/guide/assets.md

+4
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,7 @@ const imgUrl = new URL(imagePath, import.meta.url).href
113113
::: warning Does not work with SSR
114114
This pattern does not work if you are using Vite for Server-Side Rendering, because `import.meta.url` have different semantics in browsers vs. Node.js. The server bundle also cannot determine the client host URL ahead of time.
115115
:::
116+
117+
::: warning Esbuild target config is necessary
118+
This pattern needs esbuild target to be set to `es2020` or higher. `vite@2.x` use `es2019` as default target. Set [build-target](https://vitejs.dev/config/#build-target) and [optimizedeps.esbuildoptions.target](https://vitejs.dev/config/#optimizedeps-esbuildoptions) to `es2020` or higher if you intend to use this partten.
119+
:::

0 commit comments

Comments
 (0)