Skip to content

Commit

Permalink
ci: split out rollup configs into dev/prod
Browse files Browse the repository at this point in the history
that way we only need to build with terser if we need to!
  • Loading branch information
kanadgupta committed Nov 16, 2024
1 parent 9602348 commit ad3b864
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,10 @@ jobs:
path: oas-examples-repo
repository: readmeio/oas-examples

# For every GitHub Action release, we deploy our Docker images
# to the GitHub Container Registry for performance reasons.
# Instead of testing against the pre-built image, we can build
# an image from the currently checked-out repo contents by doing a
# li'l update in the action.yml file to point to the current Dockerfile.
# - name: Replace Docker image value in action.yml
# uses: jacobtomlinson/gha-find-replace@v3
# with:
# find: 'image:.*'
# replace: "image: 'Dockerfile'"
# include: rdme-repo/action.yml
# TODO: write a smol explainer comment
- name: Rebuild GitHub Action for testing purposes
run: 'npm run build:gha'
working-directory: rdme-repo

- name: Run `openapi:validate` command
uses: ./rdme-repo/
Expand Down
15 changes: 4 additions & 11 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,10 @@ jobs:
regex: false
include: documentation/*

# For every GitHub Action release, we deploy our Docker images
# to the GitHub Container Registry for performance reasons.
# Instead of testing against the pre-built image, we can build
# an image from the currently checked-out repo contents by doing a
# li'l update in the action.yml file to point to the current Dockerfile.
# - name: Replace Docker image value in action.yml
# uses: jacobtomlinson/gha-find-replace@v3
# with:
# find: 'image:.*'
# replace: "image: 'Dockerfile'"
# include: action.yml
# TODO: write a smol explainer comment
- name: Rebuild GitHub Action for testing purposes
run: 'npm run build:gha'
working-directory: rdme-repo

# And finally, with our updated documentation,
# we run the `rdme` GitHub Action to sync the Markdown file
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
},
"scripts": {
"build": "tsc",
"build:gha": "npm run build && rollup -c",
"build:gha": "npm run build && rollup --config",
"build:gha:prod": "npm run build:gha -- --environment PRODUCTION_BUILD",
"debug": "tsx src/cli.ts",
"lint": "alex . && knip && npm run lint:ts && npm run prettier && npm run schemas:check",
"lint:ts": "eslint . --ext .js,.ts",
Expand Down
9 changes: 8 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import replace from '@rollup/plugin-replace';
import terser from '@rollup/plugin-terser';
import { defineConfig } from 'rollup';

const isProductionBuild = process.env.PRODUCTION_BUILD === 'true';

const basePlugins = [
commonjs(),
json(),
Expand All @@ -14,9 +16,14 @@ const basePlugins = [
exportConditions: ['node'],
preferBuiltins: true,
}),
terser(),
];

// only minify when doing a "production" build (i.e., for a release)
// it takes a lot longer!
if (isProductionBuild) {
basePlugins.push(terser());
}

export default defineConfig([
{
input: 'bin/run-gha.js',
Expand Down

0 comments on commit ad3b864

Please sign in to comment.