From 2cc8b50544e6ab1a60e423b1ea1cd6ff205c5439 Mon Sep 17 00:00:00 2001 From: Dmitry Verkhoturov Date: Fri, 1 Nov 2024 23:26:05 +0100 Subject: [PATCH] Add Prettier for CSS and JS formatting in CI workflow --- .github/workflows/ci-build-site.yml | 11 +++++++++++ hugo/webpack.mix.js | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-build-site.yml b/.github/workflows/ci-build-site.yml index d2c5699e..87d1fd1f 100644 --- a/.github/workflows/ci-build-site.yml +++ b/.github/workflows/ci-build-site.yml @@ -103,6 +103,17 @@ jobs: # Copy the generated manifest.json from the new build cp ${{ steps.set-dirs.outputs.new_dir }}/hugo/data/manifest.json ${{ steps.set-dirs.outputs.new_dir }}/manifest.json + - name: Install Prettier + run: npm install -g prettier + + - name: Prettify CSS and JS in public directories + run: | + # Format all CSS and JS files in both old and new public directories for easier comparison + sudo prettier --write "${{ steps.set-dirs.outputs.old_dir }}/public/**/*.css" + sudo prettier --write "${{ steps.set-dirs.outputs.old_dir }}/public/**/*.js" + sudo prettier --write "${{ steps.set-dirs.outputs.new_dir }}/public/**/*.css" + sudo prettier --write "${{ steps.set-dirs.outputs.new_dir }}/public/**/*.js" + - name: Remove itunes:subtitle from RSS feeds before comparison run: | sed -i 's#.*##' ${{ steps.set-dirs.outputs.old_dir }}/public/podcast-archives-short.rss diff --git a/hugo/webpack.mix.js b/hugo/webpack.mix.js index 74d82d4e..88e6bb61 100644 --- a/hugo/webpack.mix.js +++ b/hugo/webpack.mix.js @@ -26,10 +26,10 @@ mix ['app', 'vendor'].forEach((style) => { mix .sass(`src/scss/${style}.scss`, '.') - .options({ postCss: [require('cssnano')] }); // Conditionally include cssnano + .options({ postCss: shouldMinify ? [require('cssnano')] : [] }); // Conditionally include cssnano mix .sass(`src/scss/${style}-dark.scss`, '.') - .options({ postCss: [require('cssnano')] }); // Conditionally include cssnano + .options({ postCss: shouldMinify ? [require('cssnano')] : [] }); // Conditionally include cssnano }); mix.webpackConfig({