From e4a4dbbedbb1e17fdd7af2aa62cd908f5a39c0f8 Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Wed, 13 Dec 2023 15:52:17 -0500 Subject: [PATCH] Fix sass minification --- gulpfile.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 79f37c3..3cf2f51 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -29,8 +29,7 @@ const webpack = require("webpack"), const isProduction = minimist(process.argv.slice(2)).production !== undefined; // Declare plugin settings -const sassOutputStyle = isProduction ? "compressed" : "expanded", - sassPaths = "node_modules", +const sassPaths = "node_modules", autoprefixerSettings = { remove: false, cascade: false }; // Include browsersync when gulp has not been run with --production @@ -95,10 +94,15 @@ function processSass(filename) { const css = gulp.src(`resources/sass/${filename}.scss`) .pipe(plumber(handleError)) .pipe(sassGlob()) - .pipe(sass({ outputStyle: sassOutputStyle })) + .pipe(sass({ quietDeps: true })) .pipe(postCSS([ autoprefixer(autoprefixerSettings) ])) - .pipe(concat(`${filename}.css`)) - .pipe(gulp.dest("public/css/")); + .pipe(concat(`${filename}.css`)); + + if (isProduction) { + css.pipe(cleanCSS()); + } + + css.pipe(gulp.dest("public/css/")); if (!isProduction) { css.pipe(browserSync.stream({ match: `**/${filename}.css` }));