forked from BibliothecaDAO/realms-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.size-limit.js
46 lines (42 loc) · 996 Bytes
/
.size-limit.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Just a basic example for size limit with simple file preset
// @link https://github.com/ai/size-limit
let manifest;
try {
manifest = require('./.next/build-manifest.json');
} catch (e) {
throw new Error(
'Cannot find a NextJs build folder, did you forget to build ?'
);
}
const pages = manifest.pages;
const limitCfg = {
defaultSize: '450kb',
pages: {
// Customize specific page limits if needed
'/_app': '1600kb',
'/_error': '105kb',
'/404': '100kb',
'/': '1200kb',
'/demo': '105kb',
'/home': '100kb',
},
};
const getPageLimits = () => {
let pageLimits = [];
for (const [uri, paths] of Object.entries(pages)) {
pageLimits.push({
name: `Browser page '${uri}'`,
limit: limitCfg.pages?.[uri] ?? limitCfg.defaultSize,
path: paths.map((p) => `.next/${p}`),
});
}
return pageLimits;
};
module.exports = [
...getPageLimits(),
{
name: 'CSS',
path: ['.next/static/css/**/*.css'],
limit: '10 kB',
},
];