21 lines
524 B
Plaintext
21 lines
524 B
Plaintext
|
function getProxyCode(options, isSSR) {
|
||
|
const stringifiedFSPath = JSON.stringify(options.fsPath);
|
||
|
return `
|
||
|
new Proxy(${JSON.stringify(options)}, {
|
||
|
get(target, name, receiver) {
|
||
|
if (name === 'clone') {
|
||
|
return structuredClone(target);
|
||
|
}
|
||
|
if (name === 'fsPath') {
|
||
|
return ${stringifiedFSPath};
|
||
|
}
|
||
|
${!isSSR ? `globalThis.astroAsset.referencedImages.add(${stringifiedFSPath});` : ""}
|
||
|
return target[name];
|
||
|
}
|
||
|
})
|
||
|
`;
|
||
|
}
|
||
|
export {
|
||
|
getProxyCode
|
||
|
};
|