Skip to content

Commit

Permalink
add a special case for sharp
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed Dec 1, 2023
1 parent eb01405 commit b3607b6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/utils/special-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ const specialCases: Record<string, (o: SpecialCaseOpts) => void> = {
emitAsset(resolve(id.replace('index.js', 'preload.js')));
}
},
'sharp' ({ id, emitAssetDirectory }) {
if (id.endsWith('sharp/lib/index.js')) {
const file = resolve(id, '..', '..', 'package.json');
const pkg = JSON.parse(readFileSync(file, 'utf8'));
for (const dep of Object.keys(pkg.optionalDependencies || {})) {
const dir = resolve(id, '..', '..', '..', dep);
emitAssetDirectory(dir);
}
}
},
'shiki' ({ id, emitAssetDirectory }) {
if (id.endsWith('/dist/index.js')) {
emitAssetDirectory(resolve(dirname(id), '..', 'languages'));
Expand Down

0 comments on commit b3607b6

Please sign in to comment.