Skip to content

Commit e06d469

Browse files
committed
feat: gatsby-plugin
1 parent 7d630f9 commit e06d469

File tree

13 files changed

+3221
-17
lines changed

13 files changed

+3221
-17
lines changed

README.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
- [Webpack configuration](#webpack-configuration-1)
3232
- [Usage](#usage)
3333
- [Compare mode](#compare-mode-1)
34-
- [Standalone web application](#3-standalone-web-application)
35-
- [:zap: Running on CI](#4-zap-running-on-ci)
36-
- [Packages](#5-packages)
34+
- [Gatsby plugin](#3-gatsby-plugin)
35+
- [Standalone web application](#4-standalone-web-application)
36+
- [:zap: Running on CI](#5-zap-running-on-ci)
37+
- [Packages](#6-packages)
3738

3839
## 1. Webpack plugin
3940

@@ -227,13 +228,19 @@ Reports saved:
227228

228229
The option can be disabled using `--no-compare` option.
229230

230-
## 3. Standalone web application
231+
## 3. Gatsby plugin
232+
233+
Install `bundle-stats` as a Gatsby plugin.
234+
235+
[Read more](packages/gatsby-plugin)
236+
237+
## 4. Standalone web application
231238

232239
Use https://compare.relative-ci.com to compare Webpack/Lighthouse/Browsertime stats.
233240

234-
[Read more](/packages/web-compare)
241+
[Read more](packages/web-compare)
235242

236-
## 4. :zap: Running on CI
243+
## 5. :zap: Running on CI
237244

238245
Continuous monitoring with BundleStats on CI:
239246
- Github Checks integration
@@ -242,20 +249,24 @@ Continuous monitoring with BundleStats on CI:
242249

243250
[Read more about running BundleStats on CI (BETA)](https://relative-ci.com)
244251

245-
## 5. Packages
252+
## 6. Packages
246253

247-
### [`bundle-stats`](/packages/cli)
254+
### [`bundle-stats`](packages/cli)
248255

249256
Generate bundle report based on Webpack stats data.
250257

251-
### [`@bundle-stats/web-compare`](/packages/web-compare)
258+
### [`gatsby-plugin-bundle-stats`](packages/gatsby-plugin)
259+
260+
Gatsby plugin for bundle stats
261+
262+
### [`@bundle-stats/web-compare`](packages/web-compare)
252263
Side by side comparison for webpack/lighthouse/browsertime stats - https://compare.relative-ci.com.
253264

254-
### [`@bundle-stats/html-templates`](/packages/html-templates)
265+
### [`@bundle-stats/html-templates`](packages/html-templates)
255266
HTML templates for report generation.
256267

257-
### [`@bundle-stats/ui`](/packages/ui)
268+
### [`@bundle-stats/ui`](packages/ui)
258269
UI components for BundleStats projects.
259270

260-
### [`@bundle-stats/utils`](/packages/utils)
271+
### [`@bundle-stats/utils`](packages/utils)
261272
Utilities for BundleStats projects.

packages/bundle-stats/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
- [Webpack configuration](#webpack-configuration-1)
3232
- [Usage](#usage)
3333
- [Compare mode](#compare-mode-1)
34-
- [Standalone web application](#3-standalone-web-application)
35-
- [:zap: Running on CI](#4-zap-running-on-ci)
34+
- [Gatsby plugin](#3-gatsby-plugin)
35+
- [Standalone web application](#4-standalone-web-application)
36+
- [:zap: Running on CI](#5-zap-running-on-ci)
3637

3738
## 1. Webpack plugin
3839

@@ -226,13 +227,19 @@ Reports saved:
226227

227228
The option can be disabled using `--no-compare` option.
228229

229-
## 3. Standalone web application
230+
## 3. Gatsby plugin
231+
232+
Install `bundle-stats` as a Gatsby plugin.
233+
234+
[Read more](../gatsby-plugin)
235+
236+
## 4. Standalone web application
230237

231238
Use https://compare.relative-ci.com to compare Webpack/Lighthouse/Browsertime stats.
232239

233240
[Read more](../web-compare)
234241

235-
## 4. :zap: Running on CI
242+
## 5. :zap: Running on CI
236243

237244
Continuous monitoring with BundleStats on CI:
238245
- Github Checks integration

packages/bundle-stats/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bundle-stats",
33
"version": "1.5.2",
4-
"description": "In-depth reports for webpack bundles",
4+
"description": "In-depth bundle analyzer for webpack(bundle size, assets, modules)",
55
"main": "lib/index.js",
66
"bin": {
77
"bundle-stats": "bin/index.js"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
extends: 'airbnb-base',
3+
parserOptions: {
4+
sourceType: 'script',
5+
},
6+
rules: {
7+
'import/prefer-default-export': 0,
8+
strict: 0,
9+
},
10+
};

packages/gatsby-plugin/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
.DS_Store
3+
Thumbs.db
4+
.idea/
5+
.vscode/
6+
*.sublime-project
7+
*.sublime-workspace
8+
*.log

packages/gatsby-plugin/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.eslintrc.js
2+
jsconfig.json

packages/gatsby-plugin/LICENSE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# The MIT License
2+
3+
Copyright 2019 Viorel Cojocaru, contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

packages/gatsby-plugin/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# gatsby-plugin-bundle-stats
2+
3+
[Gatsby](https://www.gatsbyjs.org) plugin for [bundle-stats](../bundle-stats).
4+
5+
## Description
6+
7+
In-depth bundle analyzer for webpack(bundle size, assets, modules)
8+
9+
## How to install
10+
11+
```shell
12+
npm install --dev gatsby-plugin-bundle-stats
13+
```
14+
15+
or
16+
17+
```shell
18+
yarn add --dev gatsby-plugin-bundle-stats
19+
```
20+
21+
## Available options
22+
23+
See [bundle-stats available options](../bundle-stats/#bundlestatswebpackpluginoptions).
24+
25+
## Examples of usage
26+
27+
```js
28+
// In your gatsby-config.js
29+
module.exports = {
30+
plugins: [
31+
'gatsby-plugin-bundle-stats'
32+
]
33+
};
34+
```
35+
36+
or with custom options
37+
38+
```js
39+
// In your gatsby-config.js
40+
module.exports = {
41+
plugins: [
42+
{
43+
resolve: 'gatsby-plugin-bundle-stats',
44+
options: {
45+
compare: true,
46+
outDir: '../artifacts',
47+
stats: {
48+
context: './src'
49+
}
50+
}
51+
},
52+
]
53+
};
54+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { BundleStatsWebpackPlugin } = require('bundle-stats');
2+
3+
exports.onCreateWebpackConfig = ({ stage, actions }, options) => {
4+
if (stage === 'build-javascript') {
5+
actions.setWebpackConfig({
6+
plugins: [
7+
new BundleStatsWebpackPlugin(options),
8+
],
9+
});
10+
}
11+
};

packages/gatsby-plugin/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// noop

0 commit comments

Comments
 (0)