-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
67 lines (60 loc) · 1.94 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* This file is part of con4gis, the gis-kit for Contao CMS.
* @package con4gis
* @version 10
* @author con4gis contributors (see "authors.txt")
* @license LGPL-3.0-or-later
* @copyright (c) 2010-2025, by Küstenschmiede GmbH Software & Design
* @link https://www.con4gis.org
*/
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const sass = require('gulp-sass')(require('sass'));
const autoprefixer = require('gulp-autoprefixer');
const notify = require('gulp-notify');
const cleanCSS = require('gulp-clean-css');
const rename = require('gulp-rename');
const customPath = 'src/Resources/public/';
const paths = {
src: {
styles: customPath + 'src/scss/*.scss',
},
dist: {
styles: customPath + 'dist/css',
stylesMin: customPath + 'dist/css',
},
watch: {
styles: customPath + 'src/scss/**/*.scss',
},
};
// reading your sass files, add autoprefixer options, create sourcemaps, generate css file, inject css via browser-sync
const styles = function () {
return gulp.src(paths.src.styles)
.pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')}))
.pipe(sass())
.pipe(autoprefixer({
cascade: false
}))
.pipe(cleanCSS({format: "beautify"}))
.pipe(gulp.dest(paths.dist.styles));
};
exports.styles = styles;
// nearly the same that ['styles'] does, but minify css via cleanCSS
const minifyCss = function () {
return gulp.src(paths.src.styles)
.pipe(plumber())
.pipe(sass())
.pipe(autoprefixer({
cascade: false
}))
.pipe(cleanCSS())
.pipe(rename({extname: '.min.css'}))
.pipe(gulp.dest(paths.dist.styles));
};
exports.minify_css = minifyCss;
const watch = function (done) {
gulp.watch(paths.watch.styles, gulp.series([styles]));
done();
};
exports.default = gulp.parallel([watch]);
exports.deploy = gulp.series([styles, minifyCss]);