Repository navigation
Description
Hi everyone!
I have a problem with adding new asset to compilations.assets array.
Last week i solved some problems with it but i have the main and the last one (I hope so).
I have a plugin that generates new asset:
var sprite = oneSvg + secondSvg;
compiler.plugin('emit', function(compilation, callback) {
compilation.assets['svg/my-sprite.' + self.hash(sprite) + '.svg'] = {
source: function() { return new Buffer(sprite) },
size: function() { return Buffer.byteLength(this.source(), 'utf8'); }
}
callback();
});After plugin work I have my-sprite.svg - it have hash (I wrote simple crypto function for it), it added to compilation.assets webpack array and it appeared in destination path in hashed view like my-sprite.e5b4f3c18671eebfefa8bae79a760728.svg.
So it seems that everything is ok but my new asset doesn't appear in manifest.json that i collect by manifest-revision-webpack-plugin.
This plugin makes manifest of files and you can set format to it.
But it takes asset from compilations.stats object like:
compiler.plugin('done', function (stats) {
var data = stats.toJson(options);
var parsedAssets = self.parsedAssets(data.modules);And now problems:
Assets added by code like I wrote above (compiler.plugin('emit'...) adding assets to stats.assets array but not to stats.modules. I made the issue with it.
So at first I decided to make a pull request to this repository to change data.modules to data.stats and to make some fixes in parsedAssets function and solve the problem.
But then i see that stats.modules had the name of asset in one of fields without hash - and this is the main thing.
Because I want manifest.json to look like this:

And i didn't have it (names without hashes) in stats.assets array:
So 2 things:
- I have my added asset in
stats.assetsbut not instats.modules - I have names of assets without hashes in
stats.modulesbut not instats.assets
And the link with repo for describing this situation, I made it specially for it:
Thank you!
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
sokra commentedon Jul 23, 2015
This is a manifest-revision-webpack-plugin issue.
lgordey commentedon Jul 23, 2015
No, Tobias, that's not quite right.
Sure I'll send pull request to manifest-revision-webpack-plugin, but at first I shoud have field in
compilations.assetsto have file.name or file paths without hash.Cause if I generate name with hash myself I should send it to
compilation.assetsarray, otherwise I can't use it in manifest in my case.Now I have only this fields:
Can we add one more field?
For example I can add it from my plugin like:
Now of course this does not work because I see in
Stats.js:So we can add one more field to obj and after that I could change manifest-revision-webpack-plugin to take assets array from it.
Because now there is now way to send to versions of file name (with and without hash) and use it after this in other plugins as:
lgordey commentedon Jul 24, 2015
We need smth like name in module section
but for the
compilations.assetsobject