Skip to content

Commit

Permalink
Document gzip and brotli compression in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
woodcox authored Jan 13, 2024
1 parent c2f3035 commit 6e1e9b4
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ plugins: [
~~~

## Environment variables
The `pathPrefix` npm script argument from 11ty is passed through as an environment variable using [esbuild's define api](https://esbuild.github.io/api/#define). You can add other environment variables by adding them to the defineEnv const in the `config/build/esbuild.js` script.
The `pathPrefix` npm script argument from 11ty (`--pathprefix=form-2-pdf",
`) is passed through as an environment variable (along with all the npm script arguments) using [esbuild's define api](https://esbuild.github.io/api/#define). You can add other environment variables by adding them to the defineEnv const in the `config/build/esbuild.js` script.

~~~js
const defineEnv = {
Expand All @@ -161,9 +162,9 @@ const defineEnv = {
};
~~~

If you decide to use a client-side router such as [solid router](https://github.com/solidjs/solid-router) you could do the following:
If you decide to use a client-side router such as [solid router](https://github.com/solidjs/solid-router) you could do the following in your jsx:

~~~js
~~~jsx
const pathPrefix = process.env.PATHPREFIX;
const urlPrefix = pathPrefix ? `/${pathPrefix}` : "";

Expand All @@ -179,6 +180,26 @@ render(
);
~~~

## Compression - Gzip and Brotli

In a production build the css and js files are automatically compressed and output as minified, gzipped and brotli files:

- `app-S5YUTCHU.min.js`
- `app-S5YUTCHU.min.js.br`
- `app-S5YUTCHU.min.js.gz`

To alter this behaviour modifiy the following in the `config/build/esbuild.js` script:

~~~js
if (isProd) {
esbuildOpts.plugins.push(gzipPlugin({
uncompressed: isProd,
gzip: isProd,
brotli: isProd,
}));
}
~~~

## Development Scripts

**`npm start`**
Expand Down

0 comments on commit 6e1e9b4

Please sign in to comment.