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

Bundle analyzer #653

Merged
merged 4 commits into from
Nov 10, 2021
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
27 changes: 23 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
node-version: 14.x
- name: upgrade gitalk
run: npm upgrade gitalk
- name: npm install and build
- name: npm install
env:
GATSBY_GITHUB_CLIENT_SECRET: ${{secrets.GATSBY_GITHUB_CLIENT_SECRET}}
GATSBY_GITHUB_CLIENT_ID: ${{secrets.GATSBY_GITHUB_CLIENT_ID}}
Expand All @@ -77,9 +77,28 @@ jobs:
FAUNADB_SERVER_SECRET: ${{secrets.FAUNADB_SERVER_SECRET}}
NETLIFY_ENV: production
PERCY_TOKEN: ${{secrets.PERCY_TOKEN}}
run: |
npm install
npm run build
run: npm install
- name: npm build
env:
GATSBY_GITHUB_CLIENT_SECRET: ${{secrets.GATSBY_GITHUB_CLIENT_SECRET}}
GATSBY_GITHUB_CLIENT_ID: ${{secrets.GATSBY_GITHUB_CLIENT_ID}}
GATSBY_ALGOLIA_SEARCH_API_KEY: ${{secrets.GATSBY_ALGOLIA_SEARCH_API_KEY}}
GATSBY_ALGOLIA_INDEX_NAME: ${{secrets.GATSBY_ALGOLIA_INDEX_NAME}}
GATSBY_ALGOLIA_APP_ID: ${{secrets.GATSBY_ALGOLIA_APP_ID}}
GATSBY_ALGOLIA_ADMIN_API_KEY: ${{secrets.GATSBY_ALGOLIA_ADMIN_API_KEY}}
GATSBY_GITHUB_SHA: ${{ github.sha }}
FAUNADB_SERVER_SECRET: ${{secrets.FAUNADB_SERVER_SECRET}}
NETLIFY_ENV: production
PERCY_TOKEN: ${{secrets.PERCY_TOKEN}}
run: npm run build
- name: Push Bundle Analyze
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public/bundle-report.html
keep_files: true
- name: Remove Bundle Analyze
run: rm ./public/bundle-report.html
- name: Deploy to netlify
run: npx netlify-cli deploy --prod --dir=./public
env:
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/previewDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ jobs:
with:
name: main.spec.js.mp4
path: ./cypress/videos/e2e/main.spec.js.mp4
- uses: actions/upload-artifact@v2
with:
name: bundle_analyzer.png
path: ./cypress/snapshots/actual/e2e/main.spec.js/bundle_analyzer.png

build:
runs-on: ubuntu-latest
Expand All @@ -63,7 +67,7 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: npm install and build
- name: npm install
env:
GATSBY_GITHUB_CLIENT_SECRET: ${{secrets.GATSBY_GITHUB_CLIENT_SECRET}}
GATSBY_GITHUB_CLIENT_ID: ${{secrets.GATSBY_GITHUB_CLIENT_ID}}
Expand All @@ -74,9 +78,19 @@ jobs:
GATSBY_GITHUB_SHA: ${{ github.sha }}
FAUNADB_SERVER_SECRET: ${{secrets.FAUNADB_SERVER_SECRET}}
NETLIFY_ENV: deploy-preview
run: |
npm install
npm run build
run: npm install
- name: npm build
env:
GATSBY_GITHUB_CLIENT_SECRET: ${{secrets.GATSBY_GITHUB_CLIENT_SECRET}}
GATSBY_GITHUB_CLIENT_ID: ${{secrets.GATSBY_GITHUB_CLIENT_ID}}
GATSBY_ALGOLIA_SEARCH_API_KEY: ${{secrets.GATSBY_ALGOLIA_SEARCH_API_KEY}}
GATSBY_ALGOLIA_INDEX_NAME: ${{secrets.GATSBY_ALGOLIA_INDEX_NAME}}
GATSBY_ALGOLIA_APP_ID: ${{secrets.GATSBY_ALGOLIA_APP_ID}}
GATSBY_ALGOLIA_ADMIN_API_KEY: ${{secrets.GATSBY_ALGOLIA_ADMIN_API_KEY}}
GATSBY_GITHUB_SHA: ${{ github.sha }}
FAUNADB_SERVER_SECRET: ${{secrets.FAUNADB_SERVER_SECRET}}
NETLIFY_ENV: deploy-preview
run: npm run build
- name: Deploy to netlify
run: npx netlify-cli deploy --dir=./public > cli.txt
env:
Expand Down
7 changes: 7 additions & 0 deletions cypress/integration/e2e/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ describe("UI Test", () => {
cy.window().its('scrollY').should('be.lt', 100);
});
});

describe("Capture Bundle Analyzer", () => {
it('Bundle Report', ()=>{
cy.visit("/bundle-report.html");
cy.screenshot('bundle_analyzer')
})
});
14 changes: 3 additions & 11 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,14 @@ module.exports = {
enable: isNetlifyProduction,
},
},
// {
// resolve: 'gatsby-plugin-purgecss',
// options: {
// printRejected: true,
// ignore: ['static/']

// },
// },
{
resolve: 'gatsby-remark-copy-linked-files',
},
{
resolve: 'gatsby-plugin-webpack-bundle-analyzer',
resolve: 'gatsby-plugin-webpack-bundle-analyser-v2',
options: {
openAnalyzer: false,
production: true,
analyzerMode: 'static',
reportFilename: 'bundle-report.html',
},
},
{
Expand Down
Loading