Skip to content
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

Unable to control which assets are inlined when build.lib is set #7656

Closed
7 tasks done
vndre opened this issue Apr 9, 2022 · 1 comment
Closed
7 tasks done

Unable to control which assets are inlined when build.lib is set #7656

vndre opened this issue Apr 9, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists pending triage

Comments

@vndre
Copy link

vndre commented Apr 9, 2022

Describe the bug

Is there a reason with assets are forced to be inlined when build.lib is configured?

I'm currently developing a React component library and 99% of assets are simple svg icons so inlining them seems ok but I got a component that imports a (relative big) JPG image. It is a component that is going to be rendered only under specific circumstances so inlining the converted base64 string doesn't make much sense for the rest of the code, and also the fact the base64 is not an "optimized" format and the final transform is actually bigger than the actual file:

original file size: 50 KB
inline base64 string: 67.53 KB

I know this example is just a few KB of difference but the more inline assets the bigger (and noisy) the build will be.

Could be there an option to force an asset to be always external? like import assetUrl from './asset.xx?no-inline'?

Reproduction

https://stackblitz.com/edit/vitejs-vite-z4eivh?file=main.js&terminal=dev

System Info

Binaries:
    Node: 17.4.0 - ~/n/bin/node
    Yarn: 3.2.0 - ~/n/bin/yarn
    npm: 8.3.1 - ~/n/bin/npm

Used Package Manager

pnpm

Logs

No response

Validations

@sapphi-red
Copy link
Member

I think this issue is a duplicate of #4454 or #3295.

@sapphi-red sapphi-red added the duplicate This issue or pull request already exists label Apr 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists pending triage
Projects
None yet
Development

No branches or pull requests

2 participants