Skip to content

Commit

Permalink
docs: warning for new URL(url, import.meta.url) (#7279)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaomeng1900 authored Apr 8, 2022
1 parent c02537b commit 09c4fc0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/guide/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,7 @@ const imgUrl = new URL(imagePath, import.meta.url).href
::: warning Does not work with SSR
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.
:::
::: warning Esbuild target config is necessary
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.
:::

0 comments on commit 09c4fc0

Please sign in to comment.