KNACSS/gulpfile.js

77 lines
1.8 KiB
JavaScript
Raw Normal View History

2019-07-17 17:32:39 +02:00
// Note : this gulpfile works with gulp 3.9.1. Won't work with gulp 4
// 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');
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
var plugins = [
unprefix(),
2019-07-17 10:59:19 +02:00
autoprefixer({
2019-07-17 16:21:59 +02:00
grid: true
2019-07-17 10:59:19 +02:00
}),
flexbugs(),
gaps()
];
var pluginsProd = [
unprefix(),
2019-07-17 10:59:19 +02:00
autoprefixer({
2019-07-17 16:21:59 +02:00
grid: true
2019-07-17 10:59:19 +02:00
}),
flexbugs(),
gaps(),
cssnano()
];
// tâche cssDev = compile vers knacss-unminified.css
gulp.task('cssDev', function () {
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é
gulp.task('cssProd', function () {
return gulp.src('./sass/knacss.scss')
.pipe(sass())
.pipe(postcss(pluginsProd))
.pipe(gulp.dest('./css/'));
});
2019-07-17 10:59:19 +02:00
gulp.task('grillade', function () {
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-07-17 10:59:19 +02:00
gulp.task('grillade-flex', function () {
return gulp.src('./sass/_library/grillade-flex.scss')
.pipe(sass())
.pipe(postcss(pluginsProd))
.pipe(gulp.dest('./css/'));
});
// Watcher
2019-07-17 10:59:19 +02:00
gulp.task('watch', function () {
2018-12-10 17:17:32 +01:00
gulp.watch(['./sass/*.scss'], ['cssDev']);
});
2015-12-24 11:16:13 +01:00
gulp.task('default', ['cssDev', 'cssProd', 'grillade', 'grillade-flex']);