How do I migrate file-loader with postTransformPublicPath to asset?
See original GitHub issueWe currently apply the following file-loader configuration:
{
test: imageFileExtensions,
loader: "file-loader",
options: {
name: "[path][name].[ext]",
outputPath: url => getRelativeImagePath(url),
publicPath: url => getRelativeImagePath(url),
postTransformPublicPath: p => `__webpack_public_path__ + ${p}`
}
}
According to the docs, migrating this loader with the asset module should look something like this:
{
test: imageFileExtensions,
type: "asset/resource",
generator: {
filename: "[path][name][ext]",
outputPath: url => getRelativeImagePath(url),
publicPath: url => getRelativeImagePath(url)
// postTransformPublicPath???
}
}
However, as the commented line indicates, there is no support for the postTransformPublicPath
option in the asset module…
How would I proceed from here, any suggestions?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Migrate from file-loader with postTransformPublicPath to ...
I want to migrate file-loader to asset modules. file-loader is deprecated. I use this feature for CDN. postTransformPublicPath: (p) ...
Read more >file-loader - webpack - JS.ORG
DEPRECATED for v5: please consider migrating to asset modules . The file-loader resolves import / require() on a file into a url and...
Read more >A Note About Refactoring and Migrating a Project to ...
I tried to stop the Assets Module by following the document. It could be a way to avoid the problem. When using the...
Read more >Untitled
(png|jpe?g|gif)$/i, loader: 'file-loader', options: { outputPath: (url, resourcePath, context) => { // `resourcePath` is original absolute path to asset ...
Read more >Static Asset Handling
png during development, and become /assets/img.2d8efhg.png in the production build. The behavior is similar to webpack's file-loader . The difference is that ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
there is no
postTransformPublicPath
alternative. webpack does__webpack_public_path__ + ${p}
by defaulte.g. you have webpack.config.js
webpack will generate
/public-asset
for assets, if you need to respectoutput.publicPath
you should passgenerator.publicPath="/public/public-asset"
btw if you need to respect
output.publicPath
, you can just omitgenerator
publicPath
andoutputPath
options