UNPKG

@zohodesk/client_build_tool

Version:

A CLI tool to build web applications and client libraries

46 lines (39 loc) 1.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _GetChunkFilenameRuntimeModule = _interopRequireDefault(require("webpack/lib/runtime/GetChunkFilenameRuntimeModule")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // import { RuntimeGlobals, RuntimeModule, Template } from 'webpack'; // const GetChunkFilenameRuntimeModule = require('webpack/lib/runtime/GetChunkFilenameRuntimeModule'); // import GetChunkFilenameRuntimeModule from 'webpack/lib/runtime/GetChunkFilenameRuntimeModule'; // const first = set => { // const entry = set.values().next(); // return entry.done ? undefined : entry.value; // }; class CustomizedGetChunkFilenameRuntimeModule extends _GetChunkFilenameRuntimeModule.default { /** * @param {string} contentType the to use the content hash for * @param {string} name kind of filename * @param {string} global function name to be assigned * @param {function(Chunk): string | FilenameFunction} getFilenameForChunk functor to get the filename or function * @param {boolean} allChunks when false, only async chunks are included */ constructor(contentType, name, global, getFilenameForChunk, allChunks, variableName) { super(contentType, name, global, getFilenameForChunk, allChunks); this.contentType = contentType; this.global = global; this.getFilenameForChunk = getFilenameForChunk; this.allChunks = allChunks; this.dependentHash = true; this.variableName = variableName; } generate() { const sourceCode = super.generate().toString(); const replaceCode = sourceCode.replaceAll('"js-chunks/', `${this.variableName} + "js-chunks/`); return replaceCode; } } var _default = CustomizedGetChunkFilenameRuntimeModule; exports.default = _default;