Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize webpack bundle size #16

Merged
merged 5 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/build-perf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build Performance

on:
pull_request:
branches:
- panw-main
paths-ignore:
- demo/docs/**

jobs:
build-size:
name: Build Size Report
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "17"
cache: yarn
- uses: preactjs/compressed-size-action@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
build-script: build
clean-script: clean
pattern: "{demo/build/assets/js/*js,demo/build/assets/css/styles*css,demo/.docusaurus/globalData.json,demo/build/index.html,demo/build/docs/index.html,demo/build/docs/installation/index.html}"
strip-hash: '\.([^;]\w{7})\.'
minimum-change-threshold: 30
compression: none

build-time:
name: Build Time Perf
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: yarn
- name: Installation
run: yarn

# Ensure build with a cold cache does not increase too much
- name: Build (cold cache)
run: yarn build
timeout-minutes: 8

# Ensure build with a warm cache does not increase too much
- name: Build (warm cache)
run: yarn build
timeout-minutes: 2
# TODO post a Github comment with build with perf warnings?
1 change: 1 addition & 0 deletions demo/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const config = {
showManualAuthentication: false,
},
],
[require.resolve("./plugins/webpackOptimizer"), {}],
],

themeConfig:
Expand Down
3 changes: 3 additions & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"webpack-bundle-analyzer": "^4.5.0"
}
}
19 changes: 19 additions & 0 deletions demo/plugins/webpackOptimizer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const BundleAnalyzerPlugin =
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;

module.exports = function webpackOptimizer() {
return {
name: "docusaurus-webpack-optimizer",
configureWebpack() {
return {
plugins: [
new BundleAnalyzerPlugin({
analyzerMode: "static", // Uncomment for production builds
generateStatsFile: true,
openAnalyzer: false,
}),
],
};
},
};
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"release:changelog": "scripts/changelog.ts",
"release:version": "scripts/version.ts",
"release:publish": "scripts/publish.ts",
"clean": "rm -rf node_modules build demo/.docusaurus demo/build demo/node_modules && find packages -name node_modules -type d -maxdepth 2 -exec rm -rf {} + && find packages -name dist -type d -maxdepth 2 -exec rm -rf {} + && find packages -name lib -type d -maxdepth 2 -exec rm -rf {} + && find packages -name lib-next -type d -maxdepth 2 -exec rm -rf {} +"
"clean": "rm -rf node_modules build demo/.docusaurus demo/build demo/node_modules && find packages -name node_modules -type d -maxdepth 2 -exec rm -rf {} + && find packages -name dist -type d -maxdepth 2 -exec rm -rf {} + && find packages -name lib -type d -maxdepth 2 -exec rm -rf {} + && find packages -name lib-next -type d -maxdepth 2 -exec rm -rf {} +",
"postinstall": "patch-package"
},
"devDependencies": {
"@babel/cli": "^7.16.0",
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@types/json-schema": "^7.0.9",
"@types/lodash": "^4.14.176",
"@types/postman-collection": "^3.5.3",
"patch-package": "^6.4.7",
"utility-types": "^3.10.0"
},
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/docusaurus-theme-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"@types/mdx-js__react": "^1.5.4",
"@types/postman-collection": "^3.5.3",
"@types/rtlcss": "^3.1.1",
"concurrently": "^5.2.0"
"concurrently": "^5.2.0",
"patch-package": "^6.4.7"
},
"dependencies": {
"@docusaurus/theme-common": "2.0.0-beta.17",
Expand Down
Loading