diff --git a/config/postcss-plugins-default.js b/config/postcss-plugins-default.js index c2ccedb..88f224c 100644 --- a/config/postcss-plugins-default.js +++ b/config/postcss-plugins-default.js @@ -19,15 +19,6 @@ function postCssPlugins(config, stylesheet) { let purgeCss = purgeCssConfig && !purgeCssDisabled; return [ - $.autoprefixer(), - $.postcssurl({ - url: function (asset) { - if (!asset.url || asset.url.indexOf("base64") !== -1) { - return asset.url; - } - return $.path.relative(`${config.webdir}/${stylesheet.destDir}/`, asset.absolutePath).split("\\").join("/"); - } - }), // conditionally run PurgeCSS if any config (local or global) was found purgeCss ? $.purgecss({ content: purgeCssConfig.content, @@ -38,7 +29,17 @@ function postCssPlugins(config, stylesheet) { } ], safelist: purgeCssConfig.safelist - }) : false + }) : false, + $.postcssurl({ + url: function (asset) { + if (!asset.url || asset.url.indexOf("base64") !== -1) { + return asset.url; + } + return $.path.relative(`${config.webdir}/${stylesheet.destDir}/`, asset.absolutePath).split("\\").join("/"); + } + }), + $.autoprefixer(), + $.cssnano({ preset: ['default']}), ].filter(Boolean); // Strip falsy values (this enables conditional plugins like PurgeCSS) } diff --git a/package.json b/package.json index a629ffc..a953760 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webfactory-gulp-preset", - "version": "2.12.0", + "version": "2.13.0", "dependencies": { "@babel/core": "^7.13.8", "@babel/preset-env": "^7.13.8", @@ -9,11 +9,11 @@ "babel-loader": "^8.2.2", "browser-sync": "^2.26.7", "browserslist-config-webfactory": "^1.0.0", + "cssnano": "^6.0.1", "dotenv": "^10.0.0", "fancy-log": "^1.3.3", "gulp": "^4.0.0", "gulp-babel": "^8.0.0", - "gulp-clean-css": "github:webfactory/gulp-clean-css", "gulp-concat": "^2.3.3", "gulp-load-plugins": "^2.0.1", "gulp-postcss": "^9.0.0", diff --git a/plugins/index.js b/plugins/index.js index ee316b0..191f51c 100644 --- a/plugins/index.js +++ b/plugins/index.js @@ -18,6 +18,7 @@ module.exports = function(config) { $['argv'] = require('minimist')(process.argv.slice(2)); $['autoprefixer'] = require('autoprefixer'); $['browserSync'] = require('browser-sync').create(); + $['cssnano'] = require('cssnano'); $['log'] = require('fancy-log'); $['path'] = require('path'); $['postcssurl'] = require('postcss-url'); diff --git a/tasks/styles.js b/tasks/styles.js index 3a8cc09..2a98117 100644 --- a/tasks/styles.js +++ b/tasks/styles.js @@ -18,7 +18,6 @@ function styles(gulp, $, config) { }).on('error', $.sass.logError)) .pipe($.postcss(config.styles.postCssPlugins(config, stylesheet))) .pipe($.concat(stylesheet.name)) - .pipe($.cleanCss({ compatibility: 'ie11' })) .pipe(config.development ? $.sourcemaps.write('.') : $.through2.obj()) .pipe(gulp.dest(`${config.webdir}/${stylesheet.destDir}`)) .pipe($.browserSync.reload({ stream: true }));