IssueRaiser

add an option to not to inline assets in library mode when format is 'es'

### Clear 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. ```javascript 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 - [X] Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md) - [X] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/.github/contributing.md). - [X] Read the [docs](https://vitejs.dev/guide). - [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Posted by hronro on Jul 31, 2021, 2:21 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments

github (Software)

add an option to not to inline assets in library mode when format is 'es'

hronroJul 31, 2021, 2:21 PM

### Clear 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. ```javascript 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 - [X] Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md) - [X] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/.github/contributing.md). - [X] Read the [docs](https://vitejs.dev/guide). - [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue