@zohodesk/client_build_tool
Version:
A CLI tool to build web applications and client libraries
46 lines (38 loc) • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AddFileToManifestJson = void 0;
var _webpack = require("webpack");
var _createManifestJson = require("./createManifestJson");
const pluginName = 'AddFileToManifestJson';
class AddFileToManifestJson {
constructor(options) {
this.options = options;
}
apply(compiler) {
const {
RawSource
} = compiler.webpack.sources;
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
compilation.hooks.processAssets.tap({
name: pluginName,
stage: _webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
}, assets => {
const {
hashDigestLength
} = compilation.outputOptions;
this.options.forEach(option => {
const manifestJson = (0, _createManifestJson.createManifestJson)({
option,
hashDigestLength,
compilation,
assets
});
compilation.emitAsset(option.outputJsonFileName, new RawSource(JSON.stringify(manifestJson)));
});
});
});
}
}
exports.AddFileToManifestJson = AddFileToManifestJson;