vite
vite copied to clipboard
plugin-legacy Unexpected token import
Describe the bug
use <img src="@/assets/logo.png">
load static image
build config
legacy({ targets: ['ie >= 11', 'chrome > 49'] })
there will be new URL("logo.03d6d6da.png",import.meta.url).href
in legacy chunk file. in chrome 55, import will cause error.
Reproduction
System Info
System:
OS: Windows 10 10.0.22000
CPU: (16) x64 AMD Ryzen 7 4800U with Radeon Graphics
Memory: 5.33 GB / 15.37 GB
Binaries:
Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
npm: 8.14.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22000.120.0), Chromium (103.0.1264.62)
Internet Explorer: 11.0.22000.120
npmPackages:
@vitejs/plugin-legacy: ^2.0.0 => 2.0.0
@vitejs/plugin-vue: ^3.0.1 => 3.0.1
@vitejs/plugin-vue-jsx: ^2.0.0 => 2.0.0
vite: ^3.0.2 => 3.0.2
Used Package Manager
pnpm
Logs
No response
Validations
- [x] Follow our Code of Conduct
- [x] Read the Contributing Guidelines.
- [x] Read the docs.
- [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.