Support for manifest plugin and other modules utilizing moduleAsset hook#309
Support for manifest plugin and other modules utilizing moduleAsset hook#309skliffmueller wants to merge 1 commit intowebpack:masterfrom
Conversation
|
skliffmueller seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
| // This allows the paths to be resolved by things like the manifest plugin | ||
| compilation.hooks.moduleAsset.call({ | ||
| userRequest: file.relativeFrom | ||
| }, file.webpackTo); |
There was a problem hiding this comment.
Also not sure it is right solution, because we interpreted files as module assets
There was a problem hiding this comment.
It works for blizzard websites. And I don't see why this wouldn't work as this is how manifest plugin knows if dist path names have changed. I'll figure out test cases if I have time, otherwise it is a working solution.
https://github.com/danethurber/webpack-manifest-plugin/blob/master/lib/plugin.js#L86-L87
https://github.com/danethurber/webpack-manifest-plugin/blob/master/lib/plugin.js#L214-L216
https://github.com/danethurber/webpack-manifest-plugin/blob/master/lib/plugin.js#L42-L49
There was a problem hiding this comment.
@skliffmueller Here (https://github.com/danethurber/webpack-manifest-plugin/blob/master/lib/plugin.js#L59) we need implement hook compilation.applyPluginsAsync('webpack-manifest-plugin-before-emit', callback);
And use this hook in this plugin.
We should not pass this as module because it can break analyze tools.
There was a problem hiding this comment.
And to avoid problems with other plugins we need implement new hooks in webpack, example manifest which call after emit. It is also easy implement and feel free to ping me in webpack repo
There was a problem hiding this comment.
I don't think that will help the situation, as copy-webpack-plugin doesn't need to know what the manifest looks like, webpack-manifest-plugin needs to know what copy-webpack-plugin has modified. In webpack-manifest-plugin stats.assets from the complication object is the only point where the copy-webpack-plugin assets exist. and moduleAssets is the only object map to reference the hash file names to the original path. Otherwise it defaults to the file name.
https://github.com/danethurber/webpack-manifest-plugin/blob/master/lib/plugin.js#L88-L114
So either copy-webpack-plugin is not implemented correctly, webpack complication assets is not implemented correctly (needs to include ability to set asset name and path), or webpack-manifest-plugin isn't implemented correctly and needs to listen to an additional hook to build against the object mapping between hash file names and original file names.
There was a problem hiding this comment.
needs to listen to an additional hook to build against the object mapping between hash file names and original file names.
Yes, because adding this as module can break analyze tools, also it is not module.
Manifest plugin have 2 problem:
- Using
emithooks (it is not safe because other plugins also add assets on this hook and some assets may disappear). As i said above we need new hook inwebpackfor this. You can send a PR inwebpack, I will support you, should be easy. - Plugin should add hook for adding assets (I showed the place where it should be).
These tasks are in my todo lists, but at the moment there are more priorities, so you can start doing this and I will be happy to help.
There was a problem hiding this comment.
Okay I might not have clearly understood you at first. But I get it, we are on the same page. I will look into doing this over the weekend when work isn't chasing after me.
|
Fixed in master, now we have |
It's stupid simple. Announce to moduleAsset hook. Now original reference name links to new asset name. I'm sure this will help resolve other related conflicts with plugins and post processing against asset paths.
Issue #104