Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace gulp-clean-css with postcss-lightningcss #31

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions config/postcss-plugins-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(),
$.lightningcss({ sourceMap: false }),
].filter(Boolean); // Strip falsy values (this enables conditional plugins like PurgeCSS)
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"gulp-terser": "^2.0.1",
"minimist": "^1.2.0",
"postcss": "^8.0.9",
"postcss-lightningcss": "^0.9.0",
"postcss-url": "^10.1.3",
"stylelint": "^14.1.0",
"stylelint-config-sass-guidelines": "^9.0.1",
Expand Down
1 change: 1 addition & 0 deletions plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = function(config) {
$['log'] = require('fancy-log');
$['path'] = require('path');
$['postcssurl'] = require('postcss-url');
$['lightningcss'] = require('postcss-lightningcss');
$['purgecss'] = require('@fullhuman/postcss-purgecss');
$['through2'] = require('through2');
$['webpack'] = require('webpack');
Expand Down
1 change: 0 additions & 1 deletion tasks/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
Expand Down