KNACSS/gulpfile.js

88 lines
2 KiB
JavaScript
Raw Normal View History

// Requires
var gulp = require('gulp');
// Include plugins
var postcss = require('gulp-postcss');
2016-05-16 15:45:14 +02:00
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var cssnano = require('cssnano'); // minifies CSS
var autoprefixer = require('autoprefixer');
2019-08-12 16:48:08 +02:00
var unprefix = require('postcss-unprefix'); // deletes old prefixes
var flexbugs = require('postcss-flexbugs-fixes'); // flexbox fixes for IE
var gaps = require('postcss-gap-properties'); // gaps polyfill
2019-08-12 16:48:08 +02:00
var browsersList = [
'> 1%',
'last 2 versions',
'IE >= 10', 'Edge >= 16',
'Chrome >= 60',
'Firefox >= 50', 'Firefox ESR',
'Safari >= 10',
'ios_saf >= 10',
'Android >= 5'
];
var plugins = [
unprefix(),
2019-08-12 16:48:08 +02:00
autoprefixer({
grid: true,
browsers: browsersList
}),
flexbugs(),
gaps()
];
var pluginsProd = [
unprefix(),
2019-08-12 16:48:08 +02:00
autoprefixer({
grid: true,
browsers: browsersList
}),
flexbugs(),
gaps(),
cssnano()
];
// tâche cssDev = compile vers knacss-unminified.css
2019-08-12 16:48:08 +02:00
gulp.task('cssDev', () => {
return gulp.src('./sass/knacss.scss')
.pipe(sass({
outputStyle: 'expanded' // CSS non minifiée plus lisible ('}' à la ligne)
}))
.pipe(postcss(plugins))
.pipe(rename('knacss-unminified.css'))
.pipe(gulp.dest('./css/'));
});
// tâche cssProd = compile vers knacss.css minifié
2019-08-12 16:48:08 +02:00
gulp.task('cssProd', () => {
return gulp.src('./sass/knacss.scss')
.pipe(sass())
.pipe(postcss(pluginsProd))
.pipe(gulp.dest('./css/'));
});
2019-08-12 16:48:08 +02:00
gulp.task('grillade', () => {
return gulp.src('./sass/_library/grillade-grid.scss')
2016-05-16 15:45:14 +02:00
.pipe(sass())
.pipe(postcss(pluginsProd))
2015-12-24 09:04:43 +01:00
.pipe(gulp.dest('./css/'));
});
2019-08-12 16:48:08 +02:00
gulp.task('grillade-flex', () => {
return gulp.src('./sass/_library/grillade-flex.scss')
.pipe(sass())
.pipe(postcss(pluginsProd))
.pipe(gulp.dest('./css/'));
});
// Watcher
2019-08-12 16:48:08 +02:00
gulp.task('watch', () => {
gulp.watch(['./sass/*.scss'], gulp.series('cssDev'));
});
2019-08-12 16:48:08 +02:00
// Tâche par défaut
gulp.task('default', gulp.series('cssDev', 'cssProd', 'grillade', 'grillade-flex'));