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.
There are loaders built into esbuild that cannot be controlled (unlike loader plugins, no options can be specified), in some cases their default behavior may not work as expected, and requires some preparation of the source code before this code is processed appropriate loader.
it would seem that this is a mere trifle. After all, there is probably an option that would disable the processing of such links at the time of building, putting this part at the discretion of the developer. But the loader did not have such an option. Just as there is no option to manually set the root directory to search for the images.
It would seem like a good idea for such a narrow purpose to write an independent plugin that would deal with the processing of absolute paths in styles. But as it turned out, esbuild does not provide chain passing of execution from plugin to plugin, and thus processed files after processing went to the loader, and not to the svelte-esbuild plugin, and this completely spoiled the whole game.
And it seems to me that since it is impossible to influence loaders and introduce such functionality using plugins, it would be nice to make in such cases in the svelte-esbuild plugin itself the possibility of pre-processing the generated sources before they get processed by the corresponding loaders.
So, I suggest the following usage:
For example the above code changes all paths with
/static/images
to relative path depending on its location position