Support new URL("./image.png", import.meta.url) Asset modules
See original GitHub issueWebpack 5 support new URL("./image.png", import.meta.url)
as asset modules.
Can vite support it?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Asset Modules - webpack
To exclude assets that came from new URL calls from the asset loaders add ... path/to/asset', import.meta.url) , webpack creates an asset module...
Read more >Building: Rollup Plugin Import Meta Assets - Modern Web
Rollup plugin that detects assets references relative to modules using patterns such as new URL('./assets/my-img.png', import.meta.url) .
Read more >Bundling non-JavaScript resources - web.dev
Learn how to import and bundle various types of assets from ... image.png', import.meta.url)); ... module.wasm') with fetch(new URL('.
Read more >Angular CLI and loading assets with import.meta.url causing ...
... new URL(',,/../assets/images/noimage.png', import.meta.url);. however I get an error. Not allowed to load local resource: file url here.
Read more >Static Asset Handling - Vite
Importing Asset as URL #. Importing a static asset will return the resolved public URL when it is served: js import ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Supported since v2.4 https://github.com/vitejs/vite/commit/4cbb40d2f1a4050c9944e7e1d9e0f5b204b7e37b
That plugin just doesn’t work with vite.
If put it into
plugins
field, the code would be transformed intonew URL(import.meta.ROLLUP_FILE_URL_1, import.meta.url)
, butimport.meta.ROLLUP_FILE_URL_1
isundefined
at runtime.If put it into
build.rollupOptions.plugins
section, the generated code would be something likenew URL(new URL("foo.688baecb.png",t.url).href,t.url)', but
t.url(import.meta.url) is
undefined` in production build. So it will fail to construct URL because lack of origin.And
@web/rollup-plugin-import-meta-assets
doesn’t obeybuild.assetsInlineLimit
option.