Skip to content

Commit

Permalink
perf: purgecss for css minification integrated into webpack build
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed Feb 19, 2021
1 parent c37f9d6 commit a2b507f
Show file tree
Hide file tree
Showing 7 changed files with 489 additions and 20 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ ARG serviceWorker
RUN node schematics/customization/service-worker ${serviceWorker} || true
COPY templates/webpack/* /workspace/templates/webpack/
RUN npm run ng -- build -c ${configuration}
COPY purgecss.config.js /workspace/
RUN npm run postbuild
# synchronize-marker:pwa-docker-build:end

# ^ this part above is copied to Dockerfile_noSSR and should be kept in sync
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile_noSSR
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ ARG serviceWorker
RUN node schematics/customization/service-worker ${serviceWorker} || true
COPY templates/webpack/* /workspace/templates/webpack/
RUN npm run ng -- build -c ${configuration}
COPY purgecss.config.js /workspace/
RUN npm run postbuild
# synchronize-marker:pwa-docker-build:end

# ^ this part above is copied from the standard Dockerfile and should be kept in sync
Expand Down
7 changes: 2 additions & 5 deletions docs/guides/optimizations.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ If the PWA is built using `production` configuration. (Either by building with `
- 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).
- [PurgeCSS](https://purgecss.com) is used to remove unused CSS classes from the CSS output.
[Configuration](https://purgecss.com/configuration.html), especially whitelisting certain classes, can be done on the plugin configuration.

# Further References

Expand Down
Loading

1 comment on commit a2b507f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure Demo Servers are available:

Please sign in to comment.