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

README precompile example path separator issue #58

Closed
GravlLift opened this issue Jan 7, 2022 · 1 comment
Closed

README precompile example path separator issue #58

GravlLift opened this issue Jan 7, 2022 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@GravlLift
Copy link
Contributor

There's something strange going on with path separators on Windows in the precompile example in the readme. The path.dirname call correctly reads out the base directory as, for example, C:\\folder\\subFolder, and the path is successfully combined with the item in the url call, generating something like C:\\folder\\subFolder/./assets/image/png.

If I add a dummy plugin to esbuild, I can see that an onResolve call will then be attempted to be made to C:foldersubFolder/./assets/image/png by this plugin.

I was able to resolve the issue by either double escaping the windows path seperator...

return source.replace(
  /(url\(['"]?)(\.\.?\/)([^'")]+['"]?\))/g,
  `$1${baseDir.replace(/\\/g, '\\\\')}/$2$3`
);

... or by using / instead:

return source.replace(
  /(url\(['"]?)(\.\.?\/)([^'")]+['"]?\))/g,
  `$1${baseDir.replace(/\\/g, '/')}/$2$3`
);

I'm not exactly sure what's going on there, but at least its workaroundable.

@glromeo glromeo added the documentation Improvements or additions to documentation label Jan 8, 2022
@glromeo
Copy link
Owner

glromeo commented Mar 29, 2022

I close this hoping the documentation is clear enough now

@glromeo glromeo closed this as completed Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants