Skip to content

Commit

Permalink
docs: optimizations documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed Feb 18, 2021
1 parent 8120e5d commit ef85d1c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ kb_sync_latest_only
- [Guide - Hybrid Approach and ICM URL Rewriting](./guides/hybrid-approach-icm-url-rewriting.md)
- [Concept - Logging](./concepts/logging.md)
- [Guide - CI](./guides/continuous-integration.md)
- [Guide - Optimizations](./guides/optimizations.md)

### Third-party Integrations

Expand Down
39 changes: 39 additions & 0 deletions docs/guides/optimizations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!--
kb_guide
kb_pwa
kb_everyone
kb_sync_latest_only
-->

# Optimizations

## Nginx Optimizations

The Nginx building block applies:

- Compression of responses
- PageSpeed optimization

for further information, please refer to the [Guide - Building and Running nginx][nginx-startup].

## Custom Webpack Build

The PWA uses a customized webpack build, that opens the doors to additional optimizations.
The build can be customized in the file [`webpack.custom.ts`](../../templates/webpack/webpack.custom.ts).

If the PWA is built using `production` configuration. (Either by building with `--configuration=<other>,production` or by building the docker image with `--build-arg configuration=<other>,production`), the following optimizations are applied:

- Angular CLI [build-optimizer](https://github.com/angular/angular-cli/tree/master/packages/angular_devkit/build_optimizer#angular-build-optimizer)
- Webpack [SplitChunksPlugin](https://webpack.js.org/plugins/split-chunks-plugin/) is instructed to produce only `main`, `vendor`, `polyfills` and one `common` bundle for the code for optimized compression and download of the application.
- All `data-testing` attributes are removed from the HTML templates to reduce output.

## CSS Optimization

On npm `postbuild`, we integrated [PurgeCSS](https://purgecss.com) to remove unused CSS classes from the CSS output.
[Configuration](https://purgecss.com/configuration.html), especially whitelisting certain classes, can be done in [`purgecss.config.js`](../../purgecss.config.js).

# Further References

- [Guide - Building and Running nginx Docker Image][nginx-startup]

[nginx-startup]: ./nginx-startup.md

0 comments on commit ef85d1c

Please sign in to comment.