rollup / awesome

⚡️ Delightful Rollup Plugins, Packages, and Resources
MIT License
2.55k stars 139 forks source link

add external-assets #102

Closed recursive-beast closed 2 years ago

recursive-beast commented 2 years ago

Awesome Contribution Checklist:

Please Provide a Link A Repository for Your Addition

https://github.com/soufyakoub/rollup-plugin-external-assets

Please Describe Your Addition

Imports to assets whose resolved id matches the provided pattern(s) are made external, but the assets themselves are emitted in the final output, and the imports are correctly updated to reference the target location of those assets.

This is useful for package creators. For example, a reusable react component that imports assets and the author wants to let the user choose how to bundle them.

smart-asset does the same thing with the "copy" mode, but from my experiments, since the provided assets target directory has to be relative to the output file, it only works as expected when the output is a single chunk.

rebase does the same thing too, but I checked its source, and it seems that it's using smart-asset under the hood.

external-assets however, since most of the work is actually done by rollup:

shellscape commented 2 years ago

thanks!