Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

feat(styles-loader): disable purgecss by default #614

Merged
merged 8 commits into from
Mar 11, 2024
36 changes: 19 additions & 17 deletions packages/one-app-bundler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,22 @@ You can pass only one if you wish to customize a single build target.

#### [`purgecss`](https://github.com/FullHuman/purgecss) Options

`purgecss` is an opt-in optimization that can reduce the overall bundle size of your module by
eliminating unused css from your module's bundle. You can enable `purgecss` by setting
`bundler.purgecss.enabled` to `true` in the `one-amex` key in your module's `package.json`:

```json
{
"one-amex": {
"bundler": {
"purgecss": {
"enabled": true
}
}
}
}
```

You may add additional paths for `purgecss` to consider before stripping out
unused CSS by adding an array of glob patterns to `bundler.purgecss.paths`
under `bundler.purgecss.paths`. The example below illustrates how we would add
Expand All @@ -287,6 +303,7 @@ under `bundler.purgecss.paths`. The example below illustrates how we would add
"one-amex": {
"bundler": {
"purgecss": {
"enabled": true,
"paths": ["node_modules/some-lib/src/**/*.{js,jsx}"]
}
}
Expand All @@ -302,6 +319,7 @@ before enabling any of the following:
"one-amex": {
"bundler": {
"purgecss": {
"enabled": true,
"paths": ["node_modules/some-lib/src/**/*.{js,jsx}"],
"extractors": [{
"extractor": "purgeJs",
Expand Down Expand Up @@ -329,6 +347,7 @@ before enabling any of the following:
"one-amex": {
"bundler": {
"purgecss": {
"enabled": true,
"paths": ["node_modules/some-lib/src/**/*.{js,jsx}"],
"extractors": [{
"extractor": "purgeJs",
Expand All @@ -353,23 +372,6 @@ before enabling any of the following:
}
```

##### Disabling purgecss

`purgecss` can be disabled for your module by adding
`bundler.purgecss.disabled` as `true`. **Disabling purgecss entirely may increase your module bundle size and decrease performance.**

```json
{
"one-amex": {
"bundler": {
"purgecss": {
"disabled": true
}
}
}
}
```

#### Legacy browser support

`disableDevelopmentLegacyBundle` can be added to your bundler config and set to *true* to opt out of bundling the `legacy` assets. This will reduce bundle size and build times. This is only configured to be removed when in `development`. `production` builds will not skip the `legacy` build.
Expand Down
1 change: 0 additions & 1 deletion packages/one-app-bundler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"dependencies": {
"@americanexpress/one-app-dev-bundler": "^1.7.0",
"@americanexpress/one-app-locale-bundler": "^6.6.0",
"@americanexpress/purgecss-loader": "4.0.0",
code-forger marked this conversation as resolved.
Show resolved Hide resolved
"@babel/core": "^7.22.20",
"ajv": "^8.12.0",
"assert": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions packages/one-app-bundler/utils/validation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const purgecssSchema = Joi.object({
blocklist: Joi.array().items(Joi.string().required()),
/* eslint-enable inclusive-language/use-inclusive-words -- disables require enables */
disabled: Joi.boolean().strict(),
enabled: Joi.boolean().strict(),
});

const optionsSchema = Joi.object({
Expand Down
Loading
Loading