mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-13 01:07:18 +00:00
Merge remote-tracking branch 'origin/dev' into basis
This commit is contained in:
@@ -17,10 +17,14 @@ const prefix = 'entry-data:';
|
||||
const mainNamePlaceholder = 'ENTRY_DATA_PLUGIN_MAIN_NAME';
|
||||
const dependenciesPlaceholder = 'ENTRY_DATA_PLUGIN_DEPS';
|
||||
const placeholderRe = /(ENTRY_DATA_PLUGIN_(?:MAIN_NAME|DEPS))(\d+)/g;
|
||||
const filenamePrefix = 'static/';
|
||||
|
||||
/** @param {string} fileName */
|
||||
export function fileNameToURL(fileName) {
|
||||
return fileName.replace(/^static\//, '/');
|
||||
}
|
||||
|
||||
export default function entryDataPlugin() {
|
||||
/** @type {string} */
|
||||
/** @type {number} */
|
||||
let exportCounter;
|
||||
/** @type {Map<number, string>} */
|
||||
let counterToIdMap;
|
||||
@@ -69,14 +73,12 @@ export default function entryDataPlugin() {
|
||||
if (!chunk) throw Error(`Cannot find ${id}`);
|
||||
|
||||
if (placeholder === mainNamePlaceholder) {
|
||||
return JSON.stringify(
|
||||
chunk.fileName.slice(filenamePrefix.length),
|
||||
);
|
||||
return JSON.stringify(fileNameToURL(chunk.fileName));
|
||||
}
|
||||
|
||||
return JSON.stringify(
|
||||
getDependencies(chunks, chunk).map((item) =>
|
||||
item.slice(filenamePrefix.length),
|
||||
getDependencies(chunks, chunk).map((filename) =>
|
||||
fileNameToURL(filename),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user