rsnext/server/build/plugins/combine-assets-plugin.js
Kevin Decker 964f229f98 Sourcemap and Breakpoint Fixes (#3121)
* Propagate source maps through combine assets step

* Use constant development build id
2017-10-19 22:11:37 +02:00

32 lines
850 B
JavaScript

import { ConcatSource } from 'webpack-sources'
// This plugin combines a set of assets into a single asset
// This should be only used with text assets,
// otherwise the result is unpredictable.
export default class CombineAssetsPlugin {
constructor ({ input, output }) {
this.input = input
this.output = output
}
apply (compiler) {
compiler.plugin('compilation', (compilation) => {
compilation.plugin('optimize-chunk-assets', (chunks, callback) => {
const concat = new ConcatSource()
this.input.forEach((name) => {
const asset = compilation.assets[name]
if (!asset) return
concat.add(asset)
// We keep existing assets since that helps when analyzing the bundle
})
compilation.assets[this.output] = concat
callback()
})
})
}
}