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/sites/platform/package-lock.json b/sites/platform/package-lock.json index 4b83941d77..ee9fc1df5c 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", @@ -11177,16 +11178,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" @@ -14176,6 +14178,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", @@ -23565,9 +23583,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", @@ -25723,6 +25742,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 d0379b737f..7b93266bab 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 65821542ba..323373e92d 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", @@ -10167,16 +10168,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" @@ -12983,6 +12985,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", @@ -21461,9 +21479,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", @@ -23470,6 +23489,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 0d0688307a..65db15e8d4 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/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 diff --git a/themes/psh-docs/assets/css/main.css b/themes/psh-docs/assets/css/main.css index e662d00301..0d919edaed 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..39d77adcb1 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" | postCSS | fingerprint }} + {{ end }} - - - + - +{{ $syntaxHighlightingCSS := resources.Get "css/vendor.css" | postCSS | 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" | postCSS | fingerprint }} + {{ with .File }} {{- if eq .Dir "security/transparency/" -}} - + {{ $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 91347f1f09..393d8ef277 100644 --- a/themes/psh-docs/postcss.config.js +++ b/themes/psh-docs/postcss.config.js @@ -2,9 +2,20 @@ const themeDir = '../../themes'; module.exports = { plugins: [ + require('postcss-import'), require('tailwindcss')(themeDir + '/psh-docs/tailwind.config.js'), 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 + }] + }) + ] + : [] ] -} \ 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 +}