Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow wildcards for externals #406

Closed
Ventajou opened this issue Sep 21, 2020 · 6 comments
Closed

allow wildcards for externals #406

Ventajou opened this issue Sep 21, 2020 · 6 comments

Comments

@Ventajou
Copy link

I use Webpack as a second pass to handle things such as turning SVGs into React components, importing AngularJS HTML templates and simply placing the assets exactly where I want them. In order to do that right now I have a script that builds a list of all the files that should be treated as external by esbuild because it seems to only accept absolute paths. This adds to the overhead of running Webpack...

Would it be possible to support wildcards (or even regular expressions) to specify externals?

@zmitry
Copy link

zmitry commented Sep 21, 2020

I did similar approach but I had to move all the svgs and css to specific folder which I could exclude.

@Ventajou
Copy link
Author

I can't have everything in a single folder unfortunately.

My current approach is actually to run esbuild twice:

  • the first time I parse all the errors for unsupported file extensions and unresolvable modules and add them to the list of externals.
  • the second time is the actual build, using the externals from the first run.

This is still way faster and more accurate than any npm library I tried to get hold of the file dependency tree of my project...

@nettybun
Copy link

Does a wildcard regex as done here #420 (comment) resolve this? This is what I've been doing to have wildcard externals

@evanw
Copy link
Owner

evanw commented Nov 11, 2020

FWIW you can do this as a plugin pretty easily. The plugin API is documented here: https://esbuild.github.io/plugins/.

@Ventajou
Copy link
Author

Thanks, I'll close this. Been too busy to get into the plugins but now that they're there this will no longer be needed

evanw added a commit that referenced this issue Nov 18, 2020
@evanw
Copy link
Owner

evanw commented Nov 18, 2020

The latest release allows you to use a single * wildcard for externals such as --external:*.png or --external:/assets/*. You can still write a quick plugin if you need something super custom but hopefully wildcards can solve for common cases without needing to write a plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants