Conversation
The esbuild option `--public-path` is used to define absolute asset hosts for file loaders. Setting `--public-path=/assets` will interfere with downstream asset processing (for example Sprocket's AssetUrlProcessor), because the corresponding asset can't be found on disk. Since asset urls are rewritten anyway, removing --public-path doesn't have a negative impact. https://esbuild.github.io/api/#public-path
|
I researched more about this and I am certain that that using BUT: It seems there is too much hackery already going on relying on this, in particular javascripts imports are using this to link to files. So it is not likely that anybody will accept this change. I will do some more research on how to solve the situation. One way that helps to improve the situation is to tell |
|
I looked into this some more and realized that sourcemaps are broken out of the box in 7.2.1 with Sprockets due to the public path setting. Just run:
The sourceMappingURL was removed and replaced by a semicolon. Fundamentally, adding |
This PR removes the '--public-path=/assets` option from the generator (install.rb).
Background: The esbuild option
--public-pathis meant to be used to define alternate absolute asset hosts for file loaders. The documentation under https://esbuild.github.io/api/#public-path gives an example of--public-path=https://www.example.com/v1.Using it to prefix
/assetsis incorrect usage I believe and unnecessary.When esbuild encounters a
url(...)it will add the prefix to the rewritten url, but it will not impact the file location where the asset is stored by esbuild.Setting
--public-path=/assetswill thus interfere with downstream asset processing (for example Sprocket's AssetUrlProcessor), because the corresponding asset can't be found on disk. The asset processor is looking to resolve the prefixed URL, but can't find it becauseesbuildisn't adding the public path to files written tooutdir.I believe this went unnoticed, because using this option only affects
--loader:xxx=file(for instance when handlingttforwoff2) and when usingesbuildto handle such assets at all (for instance when importing CSS via yarn).Since asset urls are rewritten anyway, removing --public-path doesn't have a negative impact.