richardtallent / vite-plugin-singlefile

Vite plugin for inlining JavaScript and CSS resources
MIT License
808 stars 53 forks source link

Inlining small scripts #94

Closed aminya closed 2 months ago

aminya commented 5 months ago

I want to inline the small scripts (e.g. files that are under 1 KB) into my HTML. Vite (and Astro) create very small files for different components, which could be inlined instead to avoid the overhead of another HTTP request.

Is there a way to specify a size limit for the max threshold of inlining?

 [vite] dist/_astro/logo.De6d2APk.svg        0.46 kB │ gzip:  0.26 kB
 [vite] dist/_astro/Component1.DRflpVO5.js   0.14 kB │ gzip:  0.14 kB
 [vite] dist/_astro/Component2.DK5iz3Tl.js   0.74 kB │ gzip:  0.45 kB
 [vite] dist/_astro/client.BhZioPRu.js       0.90 kB │ gzip:  0.56 kB
 [vite] dist/_astro/solid.DJlj9KZv.js        10.03 kB │ gzip:  4.19 kB
Greenheart commented 3 months ago

I think this issue could be closed as out of scope for this project, based on the following paragraph from the project README:

This is a single file plugin. As in, it creates one HTML file and no other files. Hence the name. So, this either will not work or will not be optimized for apps that require multiple "entry points" (HTML files). Please see issue #51 for details. Issues opened requesting multiple entry points will be closed as wontfix.

richardtallent commented 2 months ago

This is outside the scope of this plugin, and would be best handled by adjusting how Rollup works.