source: trip-planner-front/node_modules/@angular-devkit/build-angular/src/webpack/plugins/suppress-entry-chunks-webpack-plugin.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.0 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.SuppressExtractedTextChunksWebpackPlugin = void 0;
11/**
12 * Remove .js files from entry points consisting entirely of stylesheets.
13 * To be used together with mini-css-extract-plugin.
14 */
15class SuppressExtractedTextChunksWebpackPlugin {
16 apply(compiler) {
17 compiler.hooks.compilation.tap('SuppressExtractedTextChunks', (compilation) => {
18 compilation.hooks.chunkAsset.tap('SuppressExtractedTextChunks', (chunk, filename) => {
19 // Remove only JavaScript assets
20 if (!filename.endsWith('.js')) {
21 return;
22 }
23 // Only chunks with a css asset should have JavaScript assets removed
24 let hasCssFile = false;
25 for (const file of chunk.files) {
26 if (file.endsWith('.css')) {
27 hasCssFile = true;
28 break;
29 }
30 }
31 if (!hasCssFile) {
32 return;
33 }
34 // Only chunks with all CSS entry dependencies should have JavaScript assets removed
35 let cssOnly = false;
36 const entryModules = compilation.chunkGraph.getChunkEntryModulesIterable(chunk);
37 for (const module of entryModules) {
38 cssOnly = module.dependencies.every((dependency) => dependency.constructor.name === 'CssDependency');
39 if (!cssOnly) {
40 break;
41 }
42 }
43 if (cssOnly) {
44 chunk.files.delete(filename);
45 compilation.deleteAsset(filename);
46 }
47 });
48 });
49 }
50}
51exports.SuppressExtractedTextChunksWebpackPlugin = SuppressExtractedTextChunksWebpackPlugin;
Note: See TracBrowser for help on using the repository browser.