-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support new URL("./image.png", import.meta.url) Asset modules #894
Comments
it will work in development with any file, to work in build mode you should use the public directory (the files in public will be copied by rollup to out directory) |
Should be possible with https://modern-web.dev/docs/building/rollup-plugin-import-meta-assets/ |
@jiangfengming Your plugin is not type-safe. It's URL in IDE and it's string after compile. |
fixed. |
@jiangfengming What's difference with example: https://modern-web.dev/docs/building/rollup-plugin-import-meta-assets/#examples |
That plugin just doesn't work with vite. If put it into If put it into And |
I've been poking on this as well (I'm also familiar with and have used I'm not quite sure what the answer would be for Semi-related |
Here's a demo of the new syntax with ES Modules without a bundler: https://codesandbox.io/s/import-image-paths-in-js-without-bundler-cbqpk Code: <!DOCTYPE html>
<html>
<body>
<img />
<script type="module">
const url = new URL("./wp.png", import.meta.url);
document.querySelector("img").src = url;
</script>
</body>
</html> |
Supported since v2.4 4cbb40d |
Webpack 5 support
new URL("./image.png", import.meta.url)
as asset modules.Can vite support it?
The text was updated successfully, but these errors were encountered: