Modifying URL for various assets, not just chunks
See original GitHub issueI want allot different CND for different chunk by their chunk name.
But I can’t found any arguments in methodName( )
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
URL assets bundling · Issue #795 · evanw/esbuild - GitHub
When in a JavaScript file, a call to the global URL constructor whose first argument can be evaluated to a path at build...
Read more >Asset Modules - webpack
asset /resource emits a separate file and exports the URL. Previously achievable by using file-loader . asset/inline exports a data URI of the...
Read more >Conflict: Multiple assets emit to the same filename
If your configuration creates more than a single “chunk” (as with multiple entry points or when using plugins like CommonsChunkPlugin), ...
Read more >About assets - Google Ads Help
For that reason, it's a good idea to use all the assets relevant to your ... Google Ads charges no more than two...
Read more >Getting started with embargoed assets | Contentful
Why rewrite and use an asset service at all? Why not sign the URLs immediately in the content service and return them to...
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 Free
Top 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
I spent some time looking and digging through webpack itself. I can’t find any hook or tapable event we can plug into that’s a universal overridable fn callback.
The whole purpose is to have some baseref dynamically set. Where chunks from different cdn sources can be supported simultaneously. If any plugin is close to solving the problem, it’s this one.
I’m going to spend some time on gitter with the nice folk of webpack, see what we can brainstorm!
@5punk hey, I was looking again into the issue and invested some time into trying to find a way to resolve it. I believe you want to obtain the path of imported resource as an argument to
methodName()
.So
methodName()
is invoked whenever__webpack_public_path__
is used at runtime. The problem is that__webpack_public_path__
might be accessed by any plugin, for example,file-loader
uses the following when it detectsurl('assets/bird.jpg')
CSS syntax:So, I there’s no way to know would be the full required path.
Another approach would tweak the network layer (in a manner similar to
replaceSrcMethodName
), but it also seems not feasible because not all network requests are issued by using webpack (e.g. cssurl(....)
)I can advise to use specific module / loader capabilities for manipulating the URL of a resource. E.g. https://github.com/webpack-contrib/file-loader#publicpath can be function that accepts resource name. Keep in ming, though, that the methods you provide is only invoked at build time.
If you have any suggestion / idea please share 😃