Mihael Tomić | @tomic_mihael
http://tinyurl.com/pcss-irl
Live presentation
@tomic_mihael
Just because...
...stuff.
@tomic_mihael
Nothing...
...and everything!
@tomic_mihael
It's not post-processing if it happens before hitting the browser.
Hugo Giraudel
@tomic_mihael
Pros
Cons
@tomic_mihael
Pros
Cons
@tomic_mihael
@tomic_mihael
PostCSS
libsass
less
stylus
ruby sass
1101 ms
269 ms
179 ms
77 ms
39 ms
Source: Preprocessors benchmark
@tomic_mihael
@tomic_mihael
* At the moment of presentation
1. Add PostCSS to your build tool.
@tomic_mihael
var gulp = require('gulp'),
postcss = require('gulp-postcss');
2. Select plugins and add them to your PostCSS process.
var gulp = require('gulp'),
postcss = require('gulp-postcss'),
// PostCSS plugins
mixins = require('postcss-mixins'),
simplevars = require('postcss-simple-vars'),
nested = require('postcss-nested'),
atImport = require('postcss-import');
3. Setup gulp task to dist your CSS.
@tomic_mihael
// PostCSS build task
gulp.task('cssBuild', function (){
var postCSSPlugins = [
// Import CSS file to be built with it's imports
atImport ({
from: 'src/css/app.css'
}),
// Add mixin PostCSS support
mixins,
// Add variables PostCSS support
simplevars,
// Add nesting PostCSS support
nested
];
return gulp.src('src/css/app.css')
// Add PostCSS plugins to pipe
.pipe(postcss(postCSSPlugins))
// Processed folder file destination
.pipe(gulp.dest('dist/css'))
});
4. Setup gulp task and watch your CSS changes.
@tomic_mihael
// Gulp watch task
gulp.task('styles', ['cssBuild',],
function () {
gulp.watch('src/css/*.css', ['cssBuild']);
}
)
* There are plugins for Grunt, Gulp, webpack, Broccoli, Brunch and ENB.
@tomic_mihael
Questions?