You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Monorepo for [`astro-bundle-budget`](https://www.npmjs.com/package/astro-bundle-budget) — a build-time JS/CSS bundle size budget integration for Astro.
4
+
5
+
## 📁 Structure
6
+
7
+
```
8
+
astro-bundle-budget/
9
+
├── packages/
10
+
│ └── astro-bundle-budget/ # the published npm package
11
+
└── demo/ # local Astro site for testing the integration
12
+
```
13
+
14
+
## 🚀 Getting started
15
+
16
+
Install all workspace dependencies from the root:
17
+
18
+
```bash
19
+
npm install
20
+
```
21
+
22
+
## ⚙️ Development workflow
23
+
24
+
**1️⃣ Build the package** (required before testing in the demo):
25
+
26
+
```bash
27
+
npm run build:pkg
28
+
```
29
+
30
+
Or keep it watching for changes in a separate terminal:
31
+
32
+
```bash
33
+
cd packages/astro-bundle-budget && npm run dev
34
+
```
35
+
36
+
**2️⃣ Run the demo build** to see the integration in action:
37
+
38
+
```bash
39
+
npm run build:demo
40
+
```
41
+
42
+
**3️⃣ Run both in one shot:**
43
+
44
+
```bash
45
+
npm run test:demo
46
+
```
47
+
48
+
Add these scripts to the root `package.json`:
49
+
50
+
```json
51
+
{
52
+
"scripts": {
53
+
"build:pkg": "npm run build --workspace=packages/astro-bundle-budget",
54
+
"build:demo": "npm run build --workspace=demo",
55
+
"test:demo": "npm run build:pkg && npm run build:demo"
56
+
}
57
+
}
58
+
```
59
+
60
+
## 🧪 Running tests
61
+
62
+
```bash
63
+
npm test --workspace=packages/astro-bundle-budget
64
+
```
65
+
66
+
## 📦 Package
67
+
68
+
See [`packages/astro-bundle-budget/README.md`](./packages/astro-bundle-budget/README.md) for full usage docs, options, and examples.
Build-time JS/CSS bundle size budgets for Astro. Inspect every asset and page payload at the end of `astro build` — and optionally fail CI when you exceed your thresholds.
3
+
Build-time JS/CSS bundle size budgets for Astro. Inspect every asset and page payload at the end of `astro build` — and optionally fail CI when you exceed your thresholds. 📊
4
4
5
5
```
6
6
▶ astro-bundle-budget Analysing bundle…
@@ -22,100 +22,100 @@ Build-time JS/CSS bundle size budgets for Astro. Inspect every asset and page pa
22
22
1 budget violation exceeded.
23
23
```
24
24
25
-
## Install
25
+
## 📦 Install
26
26
27
27
```bash
28
28
npm install -D astro-bundle-budget
29
29
# or
30
30
pnpm add -D astro-bundle-budget
31
31
```
32
32
33
-
## Usage
33
+
## 🛠️ Usage
34
34
35
35
```js
36
36
// astro.config.mjs
37
-
import { defineConfig } from'astro/config'
38
-
importbundleBudgetfrom'astro-bundle-budget'
37
+
import { defineConfig } from"astro/config";
38
+
importbundleBudgetfrom"astro-bundle-budget";
39
39
40
40
exportdefaultdefineConfig({
41
41
integrations: [
42
42
bundleBudget({
43
43
// Per-file limits — first matching glob wins
44
44
budgets: [
45
-
{ path:'assets/vendor-*.js', budget:'50 kB' },
46
-
{ path:'**/*.js', budget:'100 kB' },
47
-
{ path:'**/*.css', budget:'20 kB' },
45
+
{ path:"assets/vendor-*.js", budget:"50 kB" },
46
+
{ path:"**/*.js", budget:"100 kB" },
47
+
{ path:"**/*.css", budget:"20 kB" },
48
48
],
49
49
50
50
// Per-page limits — total payload a single page may reference
type:'js'|'css'|'total'// what to measure per page
95
-
budget:number|string
96
-
compression?:'none'|'gzip'|'brotli'
94
+
type:"js"|"css"|"total";// what to measure per page
95
+
budget:number|string;
96
+
compression?:"none"|"gzip"|"brotli";
97
97
}
98
98
```
99
99
100
-
### Size strings
100
+
### 📐 Size strings
101
101
102
102
Accepted formats: `'100 kB'`, `'1.5 MB'`, `'50 KB'`, `'200kb'`, `'1.2 MiB'`, or a plain number (bytes).
103
103
104
-
### Compression
104
+
### 🗜️ Compression
105
105
106
106
Set `compression: 'gzip'` or `compression: 'brotli'` to measure the wire size your users actually receive. Useful for `pageBudgets` targeting real-world performance.
107
107
108
-
## CI integration
108
+
## 🔄 CI integration
109
109
110
110
Because `failOnExceed: true` by default, `astro build` exits with code 1 when any budget is exceeded — no extra setup needed for GitHub Actions, GitLab CI, or any other CI platform.
111
111
112
112
To turn violations into warnings (still shows the table, never fails):
113
113
114
114
```js
115
-
bundleBudget({ failOnExceed:false })
115
+
bundleBudget({ failOnExceed:false });
116
116
```
117
117
118
-
## JSON report
118
+
## 📋 JSON report
119
119
120
120
Enable `report: true` to write a machine-readable report to `dist/bundle-budget-report.json`:
121
121
@@ -134,25 +134,25 @@ Enable `report: true` to write a machine-readable report to `dist/bundle-budget-
134
134
135
135
Store this file as a CI artefact and diff it between builds to track bundle growth over time.
| Static HTML report | JSON |`bundlemeta.json`|`stats.html`|
146
+
| Zero extra deps | ✓ | ✗ | ✗|
147
147
148
-
## License
148
+
## 📄 License
149
149
150
150
MIT
151
151
152
-
## Contributing
152
+
## 🤝 Contributing
153
153
154
-
Issues and PRs welcome. For questions, find us in the [`#integrations` channel on the Astro Discord](https://astro.build/chat).
154
+
Issues and PRs welcome. For questions, find us in the [`#integrations` channel on the Astro Discord](https://astro.build/chat). 💬
155
155
156
-
## Acknowledgements
156
+
## 🙏 Acknowledgements
157
157
158
-
Built with the [Astro Integration API](https://docs.astro.build/en/reference/integrations-reference/) and listed in the [Astro Integrations Library](https://astro.build/integrations/).
158
+
Built with the [Astro Integration API](https://docs.astro.build/en/reference/integrations-reference/) and listed in the [Astro Integrations Library](https://astro.build/integrations/). 🌟
0 commit comments