fix: lib build-mode causes assets to be inlined (#461) #741
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When running vite in lib mode, all assets referenced in css and js files are base64-inlined instead of being emitted as asset files.
Lib mode was apparently only enabled to avoid the warning wrt to the missing dynamic import module. However, in lib mode, the polyfill is not applied in the first place (https://vitejs.dev/config/#build-polyfilldynamicimport). So, dropping the lib mode and disabling the polyfill explicitly (polyfillDynamicImport: false) should work fine, too. Plus now assets get emitted properly (adhering to the assetsInlineLimit).
I did not find a way to test this automatically. Ideally a test would include a page that references e.g. an image by importing it and the test would check that a file is emitted. However, I could not find a way to test a post-vite build, so help is appreciated.
Tests and linting passed successfully. The example apps worked as they did before. The output of the non-lib-mode build is actually very similar to the lib-mode builds - as is expected.
I've created a changeset for this change.