source: imaps-frontend/node_modules/html-webpack-plugin/lib/chunksorter.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.2 KB
Line 
1// @ts-check
2"use strict";
3
4/** @typedef {import("webpack").Compilation} Compilation */
5
6/**
7 * @type {{[sortmode: string] : (entryPointNames: Array<string>, compilation: Compilation, htmlWebpackPluginOptions: any) => Array<string> }}
8 * This file contains different sort methods for the entry chunks names
9 */
10module.exports = {};
11
12/**
13 * Performs identity mapping (no-sort).
14 * @param {Array<string>} chunks the chunks to sort
15 * @return {Array<string>} The sorted chunks
16 */
17module.exports.none = (chunks) => chunks;
18
19/**
20 * Sort manually by the chunks
21 * @param {string[]} entryPointNames the chunks to sort
22 * @param {Compilation} compilation the webpack compilation
23 * @param {any} htmlWebpackPluginOptions the plugin options
24 * @return {string[]} The sorted chunks
25 */
26module.exports.manual = (
27 entryPointNames,
28 compilation,
29 htmlWebpackPluginOptions,
30) => {
31 const chunks = htmlWebpackPluginOptions.chunks;
32 if (!Array.isArray(chunks)) {
33 return entryPointNames;
34 }
35 // Remove none existing entries from
36 // htmlWebpackPluginOptions.chunks
37 return chunks.filter((entryPointName) => {
38 return compilation.entrypoints.has(entryPointName);
39 });
40};
41
42/**
43 * Defines the default sorter.
44 */
45module.exports.auto = module.exports.none;
Note: See TracBrowser for help on using the repository browser.