build error when importing .svg file using assets and import.meta.url #1408
-
the page in question has
(there's obviously more, but trying to include just the relevant bit). Pages using this component work fine in dev mode, this only happens with build. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
config file:
|
Beta Was this translation helpful? Give feedback.
-
Ok, so I think this repro branch (with fix) is what what you're seeing and if so, I think i can provide some thoughts on the behavior you're showing here. One thing to keep in mind when using the It might not be a big deal in the context of only running in the UI where ultimately resolving to On the server side / for bundling through, the difference would actually be important as in your example, leading with the # forward slash
# new URL('/assets/greenwood-logo.png', import.meta.url)
URL {
href: 'file:///assets/greenwood-logo.png',
origin: 'null',
protocol: 'file:',
username: '',
password: '',
host: '',
hostname: '',
port: '',
pathname: '/assets/greenwood-logo.png',
search: '',
searchParams: URLSearchParams {},
hash: ''
} # leading .
# new URL('../../assets/greenwood-logo.png', import.meta.url)
URL {
href: 'file:///Users/owenbuckley/Workspace/project-evergreen/greenwood-getting-started/src/assets/greenwood-logo.png',
origin: 'null',
protocol: 'file:',
username: '',
password: '',
host: '',
hostname: '',
port: '',
pathname: '/Users/owenbuckley/Workspace/project-evergreen/greenwood-getting-started/src/assets/greenwood-logo.png',
search: '',
searchParams: URLSearchParams {},
hash: ''
} TL;DR For now, this should work for you: private logo = new URL("../path/to/assets/TKRTipsLogo.svg", import.meta.url); That said, I am observing an issue in my repro branch that while things worked as expected with bundling and correctly inlined into the The image isn't loading in the browser and VSCode indicates the file may be corrupted? Interestingly, the source file is 7KB but the bundled output file is 12KB? 🤔 |
Beta Was this translation helpful? Give feedback.
-
Thanks again for reporting. The issue we uncovered here with static asset bundling should be all set now in the most recent release of Greenwood - v0.31.1 |
Beta Was this translation helpful? Give feedback.
OK, PRs are up for both 👍
Will get these out in a release in a few days (along with issues identified in #1405)