richardtallent / vite-plugin-singlefile

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

Fix: use relative base path to support static resources in public folder #86

Closed atomiechen closed 8 months ago

atomiechen commented 8 months ago

Fix #69 . Assets in public folder are copied to ${build.outDir} by vite and not inlined by this plugin.

We CAN work with them, however, using relative path and place all resources in the same folder.

Changes of recommended build config:

  1. Set config.base to './' to enable relative path.
  2. Set config.build.assetsDir to '' to make generated files in ${build.outDir}'s root, instead of default ${build.outDir}/assets. Then the embedded resources can be loaded by relative path.

I also updated README to inform this in Caveats.