-
I have a unique situation where I have 2 different entry files that both use the same "alias" but each of those aliases need to point to different places for each entry file. In my case, it isn't an option to use 2 different alias names. The code uses a cascading/waterfall type of file resolution for the final product..... it's a long explanation but I just can't change the alias names. Both entry files need to use the same alias "name" but each alias needs to point to different places. However from what I can tell aliases are unique per Webpack configuration. Is it possible to have unique aliases per entry file? |
BetaWas this translation helpful?Give feedback.
All reactions
Actually aliases are not unique. They are part of the resolve options which can be different per module.
You can usemodule.rules to assign different aliases per module:
{ test: /abc/, resolve: { alias: { ... } }}Replies: 2 comments 9 replies
-
You can create loader and return different content based on your complex logic (look at |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thanks. So I'm in the process of trying to see if a custom plugin would be doable for this. Never tried writing a plugin for Webpack. Do you know anything about how to use the So with Because that doesn't seem to work. I don't see any examples in the documentation on how to set this up. I would expect some sort of example on the Plugin Patterns doc page but it only shows |
BetaWas this translation helpful?Give feedback.
All reactions
-
Simple examplehttps://github.com/webpack/webpack/blob/master/lib/ExternalModuleFactoryPlugin.js, webpack has a lot of plugins side, so when you need something complex feel free to look at similar plugin logic |
BetaWas this translation helpful?Give feedback.
All reactions
-
Actually aliases are not unique. They are part of the resolve options which can be different per module. You can use |
BetaWas this translation helpful?Give feedback.
All reactions
-
If it's only a single module between the entry and the alias you could use |
BetaWas this translation helpful?Give feedback.
All reactions
-
I'm not familiar with that. Where would that resourceQuery value go? Like this? Is that how it's supposed to work? |
BetaWas this translation helpful?Give feedback.
All reactions
-
FYI I got it working perfectly. Thank you for the guidance! |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@Jakobud Can you post your solution? |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Can you post your solution? same problem |
BetaWas this translation helpful?Give feedback.