2015-04-14 10:04:17 +02:00
|
|
|
// Requires
|
|
|
|
var gulp = require('gulp');
|
|
|
|
|
|
|
|
// Include plugins
|
2018-10-31 15:24:17 +01:00
|
|
|
var postcss = require('gulp-postcss');
|
2016-05-16 15:45:14 +02:00
|
|
|
var sass = require('gulp-sass');
|
2015-04-14 10:04:17 +02:00
|
|
|
var rename = require('gulp-rename');
|
2018-10-31 15:24:17 +01:00
|
|
|
|
|
|
|
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
|
2018-10-31 15:24:17 +01:00
|
|
|
var flexbugs = require('postcss-flexbugs-fixes'); // flexbox fixes for IE
|
|
|
|
var gaps = require('postcss-gap-properties'); // gaps polyfill
|
|
|
|
|
|
|
|
var plugins = [
|
|
|
|
unprefix(),
|
2019-08-12 16:58:11 +02:00
|
|
|
autoprefixer({
|
2019-08-12 17:00:21 +02:00
|
|
|
grid: true
|
2019-08-12 16:58:11 +02:00
|
|
|
}),
|
|
|
|
flexbugs(),
|
|
|
|
gaps()
|
2018-10-31 15:24:17 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
var pluginsProd = [
|
|
|
|
unprefix(),
|
2019-08-12 16:58:11 +02:00
|
|
|
autoprefixer({
|
2019-08-12 17:00:21 +02:00
|
|
|
grid: true
|
2019-08-12 16:58:11 +02:00
|
|
|
}),
|
|
|
|
flexbugs(),
|
|
|
|
gaps(),
|
|
|
|
cssnano()
|
2018-10-31 15:24:17 +01:00
|
|
|
];
|
2015-04-14 10:04:17 +02:00
|
|
|
|
2018-10-31 15:24:17 +01:00
|
|
|
// tâche cssDev = compile vers knacss-unminified.css
|
2019-08-12 16:48:08 +02:00
|
|
|
gulp.task('cssDev', () => {
|
2018-10-31 15:24:17 +01:00
|
|
|
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', () => {
|
2018-10-31 15:24:17 +01:00
|
|
|
return gulp.src('./sass/knacss.scss')
|
|
|
|
.pipe(sass())
|
|
|
|
.pipe(postcss(pluginsProd))
|
2015-04-14 10:04:17 +02:00
|
|
|
.pipe(gulp.dest('./css/'));
|
|
|
|
});
|
|
|
|
|
2019-08-12 16:48:08 +02:00
|
|
|
gulp.task('grillade', () => {
|
2019-08-12 16:58:11 +02:00
|
|
|
return gulp.src('./sass/base/grillade-grid.scss')
|
2016-05-16 15:45:14 +02:00
|
|
|
.pipe(sass())
|
2018-10-31 15:24:17 +01:00
|
|
|
.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', () => {
|
2019-08-12 16:58:11 +02:00
|
|
|
return gulp.src('./sass/base/grillade-flex.scss')
|
2017-08-28 12:22:44 +02:00
|
|
|
.pipe(sass())
|
2018-10-31 15:24:17 +01:00
|
|
|
.pipe(postcss(pluginsProd))
|
2017-08-28 12:22:44 +02:00
|
|
|
.pipe(gulp.dest('./css/'));
|
|
|
|
});
|
|
|
|
|
2015-04-14 10:04:17 +02:00
|
|
|
// Watcher
|
2019-08-12 16:48:08 +02:00
|
|
|
gulp.task('watch', () => {
|
|
|
|
gulp.watch(['./sass/*.scss'], gulp.series('cssDev'));
|
2015-04-14 10:04:17 +02:00
|
|
|
});
|
|
|
|
|
2019-08-12 16:48:08 +02:00
|
|
|
// Tâche par défaut
|
|
|
|
gulp.task('default', gulp.series('cssDev', 'cssProd', 'grillade', 'grillade-flex'));
|