1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | exports.WebpackAssetManager = void 0;
|
---|
4 | var webpack_sources_1 = require("webpack-sources");
|
---|
5 | var WebpackAssetManager = /** @class */ (function () {
|
---|
6 | function WebpackAssetManager(outputFilename, licensesRenderer) {
|
---|
7 | this.outputFilename = outputFilename;
|
---|
8 | this.licensesRenderer = licensesRenderer;
|
---|
9 | }
|
---|
10 | WebpackAssetManager.prototype.writeChunkLicenses = function (modules, compilation, chunk) {
|
---|
11 | var text = this.licensesRenderer.renderLicenses(modules);
|
---|
12 | if (text && text.trim()) {
|
---|
13 | var filename = compilation.getPath(this.outputFilename, { chunk: chunk });
|
---|
14 | compilation.assets[filename] = new webpack_sources_1.RawSource(text);
|
---|
15 | }
|
---|
16 | };
|
---|
17 | WebpackAssetManager.prototype.writeChunkBanners = function (modules, compilation, chunk) {
|
---|
18 | var filename = compilation.getPath(this.outputFilename, { chunk: chunk });
|
---|
19 | var text = this.licensesRenderer.renderBanner(filename, modules);
|
---|
20 | if (text && text.trim()) {
|
---|
21 | var files = chunk.files instanceof Set ? Array.from(chunk.files) : chunk.files;
|
---|
22 | files
|
---|
23 | .filter(function (file) { return /\.js$/.test(file); })
|
---|
24 | .forEach(function (file) {
|
---|
25 | compilation.assets[file] = new webpack_sources_1.ConcatSource(text, compilation.assets[file]);
|
---|
26 | });
|
---|
27 | }
|
---|
28 | };
|
---|
29 | WebpackAssetManager.prototype.writeAllLicenses = function (modules, compilation) {
|
---|
30 | var text = this.licensesRenderer.renderLicenses(modules);
|
---|
31 | if (text) {
|
---|
32 | var filename = compilation.getPath(this.outputFilename, compilation);
|
---|
33 | compilation.assets[filename] = new webpack_sources_1.RawSource(text);
|
---|
34 | }
|
---|
35 | };
|
---|
36 | return WebpackAssetManager;
|
---|
37 | }());
|
---|
38 | exports.WebpackAssetManager = WebpackAssetManager;
|
---|