Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ function StatsPlugin (output, options, cache) {
this.cache = cache
}

function mergeCustomizer (objValue, srcValue) {
if (_.isArray(objValue)) {
return _.unionWith(objValue, srcValue, _.isEqual)
}
}

StatsPlugin.prototype.apply = function apply (compiler) {
var output = this.output
var options = this.options
Expand All @@ -31,7 +37,7 @@ StatsPlugin.prototype.apply = function apply (compiler) {
var result

if (cache) {
cache = _.merge(cache, stats)
cache = _.mergeWith(cache, stats, mergeCustomizer)
if (stats.errors) cache.errors = stats.errors
if (stats.warnings) cache.warnings = stats.warnings
result = JSON.stringify(cache)
Expand Down
5 changes: 5 additions & 0 deletions test/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ describe('StatsWebpackPlugin', function () {
file1: 'bundle1.js',
file2: 'bundle2.js'
}
var actualAssetNames = actual.assets.map(function (asset) {
return asset.name
})

expect(actual.assetsByChunkName).to.deep.equal(expectedAssetsByChunkName)
expect(actualAssetNames).to.include.members(['bundle1.js', 'bundle2.js'])
done()
})
})
Expand Down