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
We would like to have assets exported with the name they were imported as, as their key in the manifest file.
Example:
import"images/logo.svg"
This image would appear as images/logo.png in the manifest, independent of the actual source file location.
{
"images/logo.svg": { }
}
Technical details
Currently, the source path is used as the key, which can differ from the import name. For example, if app/assets is included in resolve.modules, the image can be imported using images/logo.png, but will be exported to the manifest as app/assets/images/logo.png.
We use the assets manifest to lookup files in the server-site application, for example, to inline the compiled SVG into the HTML page.
Another scenario is compiling different branded bundles. We run webpack multiple times with a different brand variable, which is added to the lookup path:
If a brand contains a customized image or CSS asset, when import "images/logo.svg", it will load either the branded image, or the default from app/assets. Unfortunately, they are differently exported in the asset manifest:
@jgraichen@nsunga I've published a new version of this plugin that adds rawRequest to the asset info available during customize(). It is not currently available on all assets.
The problem
We would like to have assets exported with the name they were imported as, as their key in the manifest file.
Example:
This image would appear as
images/logo.png
in the manifest, independent of the actual source file location.{ "images/logo.svg": { } }
Technical details
Currently, the source path is used as the key, which can differ from the import name. For example, if
app/assets
is included inresolve.modules
, the image can be imported usingimages/logo.png
, but will be exported to the manifest asapp/assets/images/logo.png
.Excerpt from webpack config:
Asset manifest:
We use the assets manifest to lookup files in the server-site application, for example, to inline the compiled SVG into the HTML page.
Another scenario is compiling different branded bundles. We run webpack multiple times with a different
brand
variable, which is added to the lookup path:If a brand contains a customized image or CSS asset, when
import "images/logo.svg"
, it will load either the branded image, or the default fromapp/assets
. Unfortunately, they are differently exported in the asset manifest:It would be wonderful if there would be an option to export an asset always with the exact string used to
import
it, e.g.The server application only needs to be configured with the branded asset manifest and can always look up
images/logo.svg
to load the correct image.I've made a public example here: https://github.com/jgraichen/webpack-assets-manifest-branded
Webpack version
Webpack config
https://github.com/jgraichen/webpack-assets-manifest-branded/blob/main/webpack.config.js
Operating system
The text was updated successfully, but these errors were encountered: