Fix sass minification

This commit is contained in:
Kevin MacMartin 2023-12-13 15:52:17 -05:00
parent a527fdb30a
commit e4a4dbbedb

View file

@ -29,8 +29,7 @@ const webpack = require("webpack"),
const isProduction = minimist(process.argv.slice(2)).production !== undefined; const isProduction = minimist(process.argv.slice(2)).production !== undefined;
// Declare plugin settings // Declare plugin settings
const sassOutputStyle = isProduction ? "compressed" : "expanded", const sassPaths = "node_modules",
sassPaths = "node_modules",
autoprefixerSettings = { remove: false, cascade: false }; autoprefixerSettings = { remove: false, cascade: false };
// Include browsersync when gulp has not been run with --production // 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`) const css = gulp.src(`resources/sass/${filename}.scss`)
.pipe(plumber(handleError)) .pipe(plumber(handleError))
.pipe(sassGlob()) .pipe(sassGlob())
.pipe(sass({ outputStyle: sassOutputStyle })) .pipe(sass({ quietDeps: true }))
.pipe(postCSS([ autoprefixer(autoprefixerSettings) ])) .pipe(postCSS([ autoprefixer(autoprefixerSettings) ]))
.pipe(concat(`${filename}.css`)) .pipe(concat(`${filename}.css`));
.pipe(gulp.dest("public/css/"));
if (isProduction) {
css.pipe(cleanCSS());
}
css.pipe(gulp.dest("public/css/"));
if (!isProduction) { if (!isProduction) {
css.pipe(browserSync.stream({ match: `**/${filename}.css` })); css.pipe(browserSync.stream({ match: `**/${filename}.css` }));