add an option to not to inline assets in library mode when format is 'es'
See original GitHub issueClear and concise description of the problem
Currently when using library mode, all the assets (images, videos…) are inlined using base64. When those assets are big, it takes a long for vite to build, and the browser also takes a long time to parse the javascript.
Suggested solution
When the library format is ‘es’, we can add an option to make vite emit those files, and import those files in javascript using new URL(import.meta.url, '...')
, e.g.
import foo from './image.png';
const bar = foo; // new URL(import.meta.url, './assets/image.2d8efhg.png')
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that request the same feature to avoid creating a duplicate.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:39
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Build Options
Note: the polyfill does not apply to Library Mode. ... assetsInlineLimit will be ignored and assets will always be inlined, regardless of file...
Read more >API - ESBuild
If no input files are provided then a single input file is read from stdin. The build API can take the following options:...
Read more >css-loader | webpack - JS.ORG
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >Options · Babel
would allow plugins and presets to decide that, since ES modules are supported, ... The filename is optional, but not all of Babel's...
Read more >Use the Hero web part
If the videos are set up in Hero webpart they will play inline while you can ... If you are not already in...
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
Are there any updates on that? It seems like a very common use-case for libraries – barely anyone wants fonts to be inlined in CSS.
…this works for css…
assets in
public
folderin
css
,./
dot prefix the pathin
vite.config
, build lib withes
formatthe
public
folder content is copied tolib
and paths in css are preserved → no inline assetspackage.json