Skip to content

Commit 9ec2f3f

Browse files
committed
Stop minifying review app CSS
cssnano-preset-default includes a number of transformations that meaningfully change the CSS, including [1]: - sorting declarations (css-declaration-sorter) - transforming colours (postcss-colormin) - converting values (postcss-convert-values) - merging longhand properties to shorthand (postcss-merge-longhand) - merging rules (postcss-merge-rules) - transforming fonts (postcss-minify-font-values) We are generally very intentional with the way that we author our CSS. We want the review app to reflect the code we’re writing as closely as possible. Allowing postcss to meaningfully change the CSS is confusing, and in some cases may mislead or mask problems. As a more tangible example, this configuration is currently masking the fact that `govuk-tint` and `govuk-shade` output colours defined using `rgb()` with floats which are not supported in older browsers [2] [3]. The `postcss-colormin` plugin is converting them back to hex values in the review app. Remove cssnano from the review app’s postcss config and uninstall. This doesn’t affect the minified CSS shipped in the govuk-frontend package, which is processed using the separate postcss config in the package folder. [1]: https://www.npmjs.com/package/cssnano-preset-default#plugins [2]: https://caniuse.com/mdn-css_types_color_rgb_float_values [3]: #5988
1 parent 535a931 commit 9ec2f3f

File tree

4 files changed

+1
-43
lines changed

4 files changed

+1
-43
lines changed

package-lock.json

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/govuk-frontend-review/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@
5151
"@rollup/plugin-terser": "^0.4.4",
5252
"autoprefixer": "^10.4.21",
5353
"browser-sync": "^3.0.4",
54-
"cssnano": "^7.0.7",
55-
"cssnano-preset-default": "^7.0.1",
5654
"gulp": "^5.0.0",
5755
"gulp-cli": "^3.0.0",
5856
"nodemon": "^3.1.10",

packages/govuk-frontend-review/postcss.config.mjs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import autoprefixer from 'autoprefixer'
2-
import cssnano from 'cssnano'
3-
import cssnanoPresetDefault from 'cssnano-preset-default'
42
import pseudoclasses from 'postcss-pseudo-classes'
53

64
/**
@@ -18,13 +16,6 @@ export default {
1816
pseudoclasses({
1917
allCombinations: true,
2018
restrictTo: [':link', ':visited', ':hover', ':active', ':focus']
21-
}),
22-
23-
// Always minify CSS
24-
cssnano({
25-
preset: cssnanoPresetDefault({
26-
env: 'stylesheets'
27-
})
2819
})
2920
]
3021
}

packages/govuk-frontend-review/postcss.config.unit.test.mjs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,7 @@ describe('PostCSS config', () => {
2525
it('Uses expected plugins', () => {
2626
expect(getPluginNames(config)).toEqual([
2727
'autoprefixer',
28-
'postcss-pseudo-classes',
29-
'postcss-discard-comments',
30-
'postcss-minify-gradients',
31-
'postcss-reduce-initial',
32-
'postcss-svgo',
33-
'postcss-normalize-display-values',
34-
'postcss-reduce-transforms',
35-
'postcss-colormin',
36-
'postcss-normalize-timing-functions',
37-
'postcss-calc',
38-
'postcss-convert-values',
39-
'postcss-ordered-values',
40-
'postcss-minify-selectors',
41-
'postcss-minify-params',
42-
'postcss-normalize-charset',
43-
'postcss-discard-overridden',
44-
'postcss-normalize-string',
45-
'postcss-normalize-unicode',
46-
'postcss-minify-font-values',
47-
'postcss-normalize-url',
48-
'postcss-normalize-repeat-style',
49-
'postcss-normalize-positions',
50-
'postcss-normalize-whitespace',
51-
'postcss-merge-longhand',
52-
'postcss-discard-duplicates',
53-
'postcss-merge-rules',
54-
'postcss-discard-empty',
55-
'postcss-unique-selectors',
56-
'css-declaration-sorter',
57-
'cssnano-util-raw-cache'
28+
'postcss-pseudo-classes'
5829
])
5930
})
6031
})

0 commit comments

Comments
 (0)