-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
pre-build.mjs
29 lines (25 loc) · 844 Bytes
/
pre-build.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Parcel changes names unless they're in web_accessible_resources
// `npm run build` creates additional files with hashed names
// Xcode can't handle dynamically-created filenames, so we need to keep this list here
import {readdir} from 'node:fs/promises';
import DotJson from 'dot-json';
const list = await readdir('./source', {withFileTypes: true});
const excludes = new Set([
'options.css', // Inlined, but only if excluded
'advanced-editors-messenger.js', // Inlined
'manifest.json', // Not necessary
]);
const resources = [];
for (const item of list) {
if (excludes.has(item.name)) {
continue;
}
if (item.isDirectory()) {
resources.push(item.name + '/*');
} else {
resources.push(item.name);
}
}
const manifest = new DotJson('source/manifest.json');
manifest.set('web_accessible_resources', resources);
manifest.save();