From 42e6346111db7ee873978be2904d4e3f2400e485 Mon Sep 17 00:00:00 2001 From: Tyler Mills Date: Tue, 3 Sep 2024 16:23:17 -0400 Subject: [PATCH 1/5] Add cache busting to css assets --- sites/platform/package-lock.json | 43 ++++++++++++++++--- sites/platform/package.json | 2 +- sites/upsun/package-lock.json | 43 ++++++++++++++++--- sites/upsun/package.json | 2 +- themes/psh-docs/assets/css/main.css | 2 + .../css}/print/transparency-reports.css | 0 .../css/syntax-highlighting.css | 0 .../{static => assets}/css/vendor.css | 0 .../psh-docs/layouts/partials/head/css.html | 27 +++++------- themes/psh-docs/postcss.config.js | 3 +- themes/psh-docs/tailwind.config.js | 2 +- 11 files changed, 89 insertions(+), 35 deletions(-) rename themes/psh-docs/{static/styles => assets/css}/print/transparency-reports.css (100%) rename themes/psh-docs/{static => assets}/css/syntax-highlighting.css (100%) rename themes/psh-docs/{static => assets}/css/vendor.css (100%) diff --git a/sites/platform/package-lock.json b/sites/platform/package-lock.json index ea7f041941..e9ca930054 100644 --- a/sites/platform/package-lock.json +++ b/sites/platform/package-lock.json @@ -35,6 +35,7 @@ "p-limit": "^4.0.0", "postcss": "^8.4.31", "postcss-cli": "^10.1.0", + "postcss-import": "^16.1.0", "pshregistry-parser": "^1.5.7", "remark": "^14.0.2", "remark-cli": "^11.0.0", @@ -11068,16 +11069,17 @@ } }, "node_modules/postcss-import": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-14.1.0.tgz", - "integrity": "sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==", + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-16.1.0.tgz", + "integrity": "sha512-7hsAZ4xGXl4MW+OKEWCnF6T5jqBw80/EE9aXg1r2yyn1RsVEU8EtKXbijEODa+rg7iih4bKf7vlvTGYR4CnPNg==", + "dev": true, "dependencies": { "postcss-value-parser": "^4.0.0", "read-cache": "^1.0.0", "resolve": "^1.1.7" }, "engines": { - "node": ">=10.0.0" + "node": ">=18.0.0" }, "peerDependencies": { "postcss": "^8.0.0" @@ -13999,6 +14001,22 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/tailwindcss/node_modules/postcss-import": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-14.1.0.tgz", + "integrity": "sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==", + "dependencies": { + "postcss-value-parser": "^4.0.0", + "read-cache": "^1.0.0", + "resolve": "^1.1.7" + }, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "postcss": "^8.0.0" + } + }, "node_modules/tailwindcss/node_modules/postcss-load-config": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.4.tgz", @@ -23311,9 +23329,10 @@ "requires": {} }, "postcss-import": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-14.1.0.tgz", - "integrity": "sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==", + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-16.1.0.tgz", + "integrity": "sha512-7hsAZ4xGXl4MW+OKEWCnF6T5jqBw80/EE9aXg1r2yyn1RsVEU8EtKXbijEODa+rg7iih4bKf7vlvTGYR4CnPNg==", + "dev": true, "requires": { "postcss-value-parser": "^4.0.0", "read-cache": "^1.0.0", @@ -25399,6 +25418,16 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "postcss-import": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-14.1.0.tgz", + "integrity": "sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==", + "requires": { + "postcss-value-parser": "^4.0.0", + "read-cache": "^1.0.0", + "resolve": "^1.1.7" + } + }, "postcss-load-config": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.4.tgz", diff --git a/sites/platform/package.json b/sites/platform/package.json index db171fa16e..b3452daf2f 100644 --- a/sites/platform/package.json +++ b/sites/platform/package.json @@ -11,7 +11,6 @@ "author": "Platform.sh", "scripts": { "build": "npm run fetch-files && npm run registry-files", - "build:assets": "postcss --use cssnano --no-map --output 'public/asciinema/asciinema-player-mini.css' 'public/asciinema/asciinema-player.css' && postcss --use cssnano --no-map --output 'public/css/main-mini.css' 'public/css/main.css' && postcss --use cssnano --no-map --output 'public/css/syntax-highlighting-mini.css' 'public/css/syntax-highlighting.css' && postcss --use cssnano --no-map --output 'public/css/vendor-mini.css' 'public/css/vendor.css'", "build:search": "npm run build --workspace docs-search-input", "dev": "npm run fetch-files && npm run registry-files", "fetch-files": "node utils/fetch-examples.mjs && node utils/fetchTemplates.mjs", @@ -28,6 +27,7 @@ "p-limit": "^4.0.0", "postcss": "^8.4.31", "postcss-cli": "^10.1.0", + "postcss-import": "^16.1.0", "pshregistry-parser": "^1.5.7", "remark": "^14.0.2", "remark-cli": "^11.0.0", diff --git a/sites/upsun/package-lock.json b/sites/upsun/package-lock.json index 5424093a52..d5f582bd20 100644 --- a/sites/upsun/package-lock.json +++ b/sites/upsun/package-lock.json @@ -34,6 +34,7 @@ "p-limit": "^4.0.0", "postcss": "^8.4.31", "postcss-cli": "^10.1.0", + "postcss-import": "^16.1.0", "pshregistry-parser": "^1.5.7", "remark": "^14.0.2", "remark-cli": "^11.0.0", @@ -10058,16 +10059,17 @@ } }, "node_modules/postcss-import": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-14.1.0.tgz", - "integrity": "sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==", + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-16.1.0.tgz", + "integrity": "sha512-7hsAZ4xGXl4MW+OKEWCnF6T5jqBw80/EE9aXg1r2yyn1RsVEU8EtKXbijEODa+rg7iih4bKf7vlvTGYR4CnPNg==", + "dev": true, "dependencies": { "postcss-value-parser": "^4.0.0", "read-cache": "^1.0.0", "resolve": "^1.1.7" }, "engines": { - "node": ">=10.0.0" + "node": ">=18.0.0" }, "peerDependencies": { "postcss": "^8.0.0" @@ -12806,6 +12808,22 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/tailwindcss/node_modules/postcss-import": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-14.1.0.tgz", + "integrity": "sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==", + "dependencies": { + "postcss-value-parser": "^4.0.0", + "read-cache": "^1.0.0", + "resolve": "^1.1.7" + }, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "postcss": "^8.0.0" + } + }, "node_modules/tailwindcss/node_modules/postcss-load-config": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.4.tgz", @@ -21207,9 +21225,10 @@ "requires": {} }, "postcss-import": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-14.1.0.tgz", - "integrity": "sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==", + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-16.1.0.tgz", + "integrity": "sha512-7hsAZ4xGXl4MW+OKEWCnF6T5jqBw80/EE9aXg1r2yyn1RsVEU8EtKXbijEODa+rg7iih4bKf7vlvTGYR4CnPNg==", + "dev": true, "requires": { "postcss-value-parser": "^4.0.0", "read-cache": "^1.0.0", @@ -23146,6 +23165,16 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "postcss-import": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-14.1.0.tgz", + "integrity": "sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==", + "requires": { + "postcss-value-parser": "^4.0.0", + "read-cache": "^1.0.0", + "resolve": "^1.1.7" + } + }, "postcss-load-config": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.4.tgz", diff --git a/sites/upsun/package.json b/sites/upsun/package.json index e356889108..bd1ca442bf 100644 --- a/sites/upsun/package.json +++ b/sites/upsun/package.json @@ -11,7 +11,6 @@ "author": "Platform.sh", "scripts": { "build": "npm run fetch-files && npm run registry-files", - "build:assets": "postcss --use cssnano --no-map --output 'public/asciinema/asciinema-player-mini.css' 'public/asciinema/asciinema-player.css' && postcss --use cssnano --no-map --output 'public/css/main-mini.css' 'public/css/main.css' && postcss --use cssnano --no-map --output 'public/css/syntax-highlighting-mini.css' 'public/css/syntax-highlighting.css' && postcss --use cssnano --no-map --output 'public/css/vendor-mini.css' 'public/css/vendor.css'", "build:search": "npm run build --workspace docs-search-input", "dev": "npm run fetch-files && npm run registry-files", "fetch-files": "node utils/fetch-examples.mjs && node utils/fetchTemplates.mjs", @@ -26,6 +25,7 @@ "p-limit": "^4.0.0", "postcss": "^8.4.31", "postcss-cli": "^10.1.0", + "postcss-import": "^16.1.0", "pshregistry-parser": "^1.5.7", "remark": "^14.0.2", "remark-cli": "^11.0.0", diff --git a/themes/psh-docs/assets/css/main.css b/themes/psh-docs/assets/css/main.css index 349d7d9199..ba97a1aea7 100644 --- a/themes/psh-docs/assets/css/main.css +++ b/themes/psh-docs/assets/css/main.css @@ -1,3 +1,5 @@ +/* Relative to site directory */ +@import './node_modules/asciinema-player/dist/bundle/asciinema-player.css'; /* Base TailwindCSS styles */ /* https://tailwindcss.com/docs/functions-and-directives#tailwind */ diff --git a/themes/psh-docs/static/styles/print/transparency-reports.css b/themes/psh-docs/assets/css/print/transparency-reports.css similarity index 100% rename from themes/psh-docs/static/styles/print/transparency-reports.css rename to themes/psh-docs/assets/css/print/transparency-reports.css diff --git a/themes/psh-docs/static/css/syntax-highlighting.css b/themes/psh-docs/assets/css/syntax-highlighting.css similarity index 100% rename from themes/psh-docs/static/css/syntax-highlighting.css rename to themes/psh-docs/assets/css/syntax-highlighting.css diff --git a/themes/psh-docs/static/css/vendor.css b/themes/psh-docs/assets/css/vendor.css similarity index 100% rename from themes/psh-docs/static/css/vendor.css rename to themes/psh-docs/assets/css/vendor.css diff --git a/themes/psh-docs/layouts/partials/head/css.html b/themes/psh-docs/layouts/partials/head/css.html index 5fb1174953..ac6dac58fe 100644 --- a/themes/psh-docs/layouts/partials/head/css.html +++ b/themes/psh-docs/layouts/partials/head/css.html @@ -1,31 +1,24 @@ -{{ $productionSuffix := "" }} -{{ if hugo.IsProduction }} - {{ $productionSuffix = "-mini" }} -{{ end }} - + {{ if eq .Site.Params.theme.use_vendor true }} - + {{ $vendorCSS := resources.Get "css/vendor.css" | minify | fingerprint }} + {{ end }} - - - + - +{{ $syntaxHighlightingCSS := resources.Get "css/vendor.css" | minify | fingerprint }} + -{{ $style := resources.Get "css/main.css" | resources.PostCSS }} -{{ $style = $style.RelPermalink }} -{{ if hugo.IsProduction }} - {{ $style = "/css/main-mini.css" }} -{{ end }} - +{{ $mainStyle := resources.Get "css/main.css" | resources.PostCSS | minify | fingerprint }} + {{ with .File }} {{- if eq .Dir "security/transparency/" -}} - + {{ $transparencyReportsCSS := resources.Get "css/print/transparency-reports.css" | minify | fingerprint }} + {{- end -}} {{ end }} diff --git a/themes/psh-docs/postcss.config.js b/themes/psh-docs/postcss.config.js index 91347f1f09..966ba858f0 100644 --- a/themes/psh-docs/postcss.config.js +++ b/themes/psh-docs/postcss.config.js @@ -2,9 +2,10 @@ const themeDir = '../../themes'; module.exports = { plugins: [ + require('postcss-import'), require('tailwindcss')(themeDir + '/psh-docs/tailwind.config.js'), require('autoprefixer')({ path: [themeDir] }), ] -} \ No newline at end of file +} diff --git a/themes/psh-docs/tailwind.config.js b/themes/psh-docs/tailwind.config.js index f6bd685a24..14b598502e 100644 --- a/themes/psh-docs/tailwind.config.js +++ b/themes/psh-docs/tailwind.config.js @@ -165,4 +165,4 @@ module.exports = { plugins: [ require("@tailwindcss/typography"), ], -} \ No newline at end of file +} From 3366788c8959c5d629089f0d6719ec24664ccb4e Mon Sep 17 00:00:00 2001 From: Tyler Mills Date: Tue, 3 Sep 2024 16:24:51 -0400 Subject: [PATCH 2/5] Update build workflow to match cache busting changes --- .github/workflows/pr-check-links.yaml | 1 - .platform/applications.yaml | 2 -- CONTRIBUTING.md | 2 -- build_local.sh | 5 ++--- tests.sh | 9 +++------ 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pr-check-links.yaml b/.github/workflows/pr-check-links.yaml index b76ed94383..2341efd1db 100644 --- a/.github/workflows/pr-check-links.yaml +++ b/.github/workflows/pr-check-links.yaml @@ -47,7 +47,6 @@ jobs: - name: Minify assets run: | cd sites/${{ matrix.site }} - npm run build:assets - name: Check links in Markdown run: | diff --git a/.platform/applications.yaml b/.platform/applications.yaml index 416cf8c96f..467065d284 100644 --- a/.platform/applications.yaml +++ b/.platform/applications.yaml @@ -30,7 +30,6 @@ npm install npm run build ./build_docs.sh - npm run build:assets deploy: | cd $SITE_DIR ./deploy.sh @@ -96,7 +95,6 @@ npm install npm run build ./build_docs.sh - npm run build:assets deploy: | cd $SITE_DIR ./deploy.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8e5e053c7a..c216ade01a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -171,8 +171,6 @@ To ensure the docs work smoothly, a few checks run on each pull request: npm run build:search # Build HTML pages to check hugo - # Build production JavaScript and CSS files - npm run build:assets # Run the check ./bin/htmltest ``` diff --git a/build_local.sh b/build_local.sh index 27671f52dd..f5c28d826e 100755 --- a/build_local.sh +++ b/build_local.sh @@ -17,7 +17,7 @@ clean_file () { echo "$FILE exists. Removing..." rm $FILE echo "Done." - else + else echo "$FILE does not exist. All is well." fi } @@ -36,7 +36,6 @@ npm install npm run build npm run build:search hugo -npm run build:assets clear @@ -49,4 +48,4 @@ Verify the resulting build by running the command python3 -m http.server 8888 -d sites/$BUILD_DIR/public -" \ No newline at end of file +" diff --git a/tests.sh b/tests.sh index e1b00b8d01..12c73ec019 100755 --- a/tests.sh +++ b/tests.sh @@ -17,15 +17,12 @@ npm run build:search # 3. Build Hugo site hugo -# 4. Minify assets -npm run build:assets - -# 5. Check links in Markdown +# 4. Check links in Markdown curl https://htmltest.wjdp.uk | bash bin/htmltest -# 6. Linting (Lint markdown) +# 5. Linting (Lint markdown) npm run lint:markdown -# 7. Linting (Lint prose) +# 6. Linting (Lint prose) vale src From e6c067aeb867ba1d777403e65b0977ce2c6f1807 Mon Sep 17 00:00:00 2001 From: Tyler Mills Date: Tue, 3 Sep 2024 16:58:18 -0400 Subject: [PATCH 3/5] Enable minify in config --- sites/platform/config/_default/config.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sites/platform/config/_default/config.yaml b/sites/platform/config/_default/config.yaml index 8fac5bd2fc..c827ff0013 100644 --- a/sites/platform/config/_default/config.yaml +++ b/sites/platform/config/_default/config.yaml @@ -88,3 +88,16 @@ security: http: methods: - GET + +# Minification settings +minify: + minifyOutput: true + +# Environment-specific configuration +environments: + production: + minify: + minifyOutput: true + development: + minify: + minifyOutput: false From b5f01ef70033f7d379c4f7a8a99605f1d1fdb04a Mon Sep 17 00:00:00 2001 From: Tyler Mills Date: Tue, 3 Sep 2024 16:59:01 -0400 Subject: [PATCH 4/5] Enable minify in Upsun config --- sites/upsun/config/_default/config.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sites/upsun/config/_default/config.yaml b/sites/upsun/config/_default/config.yaml index ed02d57613..32dea20c48 100644 --- a/sites/upsun/config/_default/config.yaml +++ b/sites/upsun/config/_default/config.yaml @@ -96,3 +96,16 @@ security: - ^HUGO_HEAP_ID http: methods: none + +# Minification settings +minify: + minifyOutput: true + +# Environment-specific configuration +environments: + production: + minify: + minifyOutput: true + development: + minify: + minifyOutput: false From 170dc6aa1a7b6b0c126857943db9498188954419 Mon Sep 17 00:00:00 2001 From: Tyler Mills Date: Tue, 3 Sep 2024 17:32:32 -0400 Subject: [PATCH 5/5] Use postcss for minification --- sites/platform/config/_default/config.yaml | 13 ------------- sites/upsun/config/_default/config.yaml | 13 ------------- themes/psh-docs/layouts/partials/head/css.html | 8 ++++---- themes/psh-docs/postcss.config.js | 10 ++++++++++ 4 files changed, 14 insertions(+), 30 deletions(-) diff --git a/sites/platform/config/_default/config.yaml b/sites/platform/config/_default/config.yaml index c827ff0013..8fac5bd2fc 100644 --- a/sites/platform/config/_default/config.yaml +++ b/sites/platform/config/_default/config.yaml @@ -88,16 +88,3 @@ security: http: methods: - GET - -# Minification settings -minify: - minifyOutput: true - -# Environment-specific configuration -environments: - production: - minify: - minifyOutput: true - development: - minify: - minifyOutput: false diff --git a/sites/upsun/config/_default/config.yaml b/sites/upsun/config/_default/config.yaml index 32dea20c48..ed02d57613 100644 --- a/sites/upsun/config/_default/config.yaml +++ b/sites/upsun/config/_default/config.yaml @@ -96,16 +96,3 @@ security: - ^HUGO_HEAP_ID http: methods: none - -# Minification settings -minify: - minifyOutput: true - -# Environment-specific configuration -environments: - production: - minify: - minifyOutput: true - development: - minify: - minifyOutput: false diff --git a/themes/psh-docs/layouts/partials/head/css.html b/themes/psh-docs/layouts/partials/head/css.html index ac6dac58fe..39d77adcb1 100644 --- a/themes/psh-docs/layouts/partials/head/css.html +++ b/themes/psh-docs/layouts/partials/head/css.html @@ -1,24 +1,24 @@ {{ if eq .Site.Params.theme.use_vendor true }} - {{ $vendorCSS := resources.Get "css/vendor.css" | minify | fingerprint }} + {{ $vendorCSS := resources.Get "css/vendor.css" | postCSS | fingerprint }} {{ end }} -{{ $syntaxHighlightingCSS := resources.Get "css/vendor.css" | minify | fingerprint }} +{{ $syntaxHighlightingCSS := resources.Get "css/vendor.css" | postCSS | fingerprint }} -{{ $mainStyle := resources.Get "css/main.css" | resources.PostCSS | minify | fingerprint }} +{{ $mainStyle := resources.Get "css/main.css" | postCSS | fingerprint }} {{ with .File }} {{- if eq .Dir "security/transparency/" -}} - {{ $transparencyReportsCSS := resources.Get "css/print/transparency-reports.css" | minify | fingerprint }} + {{ $transparencyReportsCSS := resources.Get "css/print/transparency-reports.css" | postCSS | fingerprint }} {{- end -}} {{ end }} diff --git a/themes/psh-docs/postcss.config.js b/themes/psh-docs/postcss.config.js index 966ba858f0..393d8ef277 100644 --- a/themes/psh-docs/postcss.config.js +++ b/themes/psh-docs/postcss.config.js @@ -7,5 +7,15 @@ module.exports = { require('autoprefixer')({ path: [themeDir] }), + ...process.env.HUGO_ENVIRONMENT === 'production' + ? [ + require('cssnano')({ + preset: ['default', { + discardComments: { removeAll: true }, // Ensure all comments are removed + normalizeWhitespace: true, // Ensures that whitespace is minimized + }] + }) + ] + : [] ] }