You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! The esbuild-plugin-meta-url is quite useful when moving from webpack to esbuild. Unfortunately it seems to default to a behaviour of reproducing the relative path to the referenced files, and trying to recreate that path, where webpack would have renamed them (in some configurable fashion) and placed them in the output directory or a configurable assets directory.
The reason this is desireable is that, well, first, it avoids having weirdly long paths embedded in your bundle in the case where the files came from somewhere deep in node_modules, but second, if the files happen to come from somewhere outside the working directory (as will be the case when using npm link), the plugin will build a directory somewhere else, possibly a place you don't want it to, or where you don't even have write permission. For example, if you have index.js:
constimg=newURL('../foo/logo.png',import.meta.url).href;console.log(`URL is ${img}`);
That's probably not what you want. This may seem kind of contrived, but as mentioned earlier, it will happen in the case where you use npm link, and in any case it would be nice to be able to collect all your assets in a folder called, perhaps, dist/assets.
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi! Sorry for the very late reply! The latest version seemed to have the same behaviour when I tried it ... two months ago (sorry again) ... not sure if there has been another one since then? I will have some time today or tomorrow to recheck this.
Hi! The
esbuild-plugin-meta-url
is quite useful when moving from webpack to esbuild. Unfortunately it seems to default to a behaviour of reproducing the relative path to the referenced files, and trying to recreate that path, where webpack would have renamed them (in some configurable fashion) and placed them in the output directory or a configurable assets directory.The reason this is desireable is that, well, first, it avoids having weirdly long paths embedded in your bundle in the case where the files came from somewhere deep in
node_modules
, but second, if the files happen to come from somewhere outside the working directory (as will be the case when usingnpm link
), the plugin will build a directory somewhere else, possibly a place you don't want it to, or where you don't even have write permission. For example, if you haveindex.js
:and
build.mjs
:Then, on running
build.js
, you will create these files:That's probably not what you want. This may seem kind of contrived, but as mentioned earlier, it will happen in the case where you use
npm link
, and in any case it would be nice to be able to collect all your assets in a folder called, perhaps,dist/assets
.The text was updated successfully, but these errors were encountered: