This repository has been archived by the owner on Jan 24, 2020. It is now read-only.
forked from viur-ignite/viur-ignite-css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·98 lines (85 loc) · 2.79 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Project data
var srcpaths = {
less: './sources/less/**/*.less',
images: './sources/images/**/*',
icons: './sources/icons/**/*',
};
var destpaths = {
css: './appengine/static/css',
html: './appengine/html',
webfonts: './appengine/static/webfonts',
images: './appengine/static/images',
icons: './appengine/html/icons'
};
// Variables and requirements
const gulp = require('gulp');
const rename = require('gulp-rename');
const less = require('gulp-less');
const path = require('path');
const postcss = require('gulp-postcss');
const zindex = require('postcss-zindex');
const autoprefixer = require('gulp-autoprefixer');
const focus = require('postcss-focus');
const nocomments = require('postcss-discard-comments');
const nano = require('gulp-cssnano');
const mmq = require('gulp-merge-media-queries');
const stylelint = require('stylelint');
const stylelintConfig = require('stylelint-config-standard');
const svgmin = require('gulp-svgmin');
const imagemin = require('gulp-imagemin');
const pngquant = require('imagemin-pngquant');
// compilation and postproduction of LESS to CSS
gulp.task('css', function () {
var processors = [
nocomments, // discard comments
focus, // add focus to hover-states
zindex, // reduce z-index values
require('stylelint')(stylelintConfig), // lint the css
require('postcss-font-magician')({
hosted: destpaths.webfonts,
formats: 'local eot woff2'
}) // import fonts
];
return gulp.src('../appengine/static/css/style.less')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
})) // compile less to css
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
})) // add vendor prefixes
.pipe(postcss(processors)) // clean up css
.pipe(mmq({
log: true
}))
.pipe(gulp.dest(destpaths.css)) // save cleaned version
.pipe(nano()) // minify css
.pipe(rename('style.min.css')) // save minified version
.pipe(gulp.dest(destpaths.css));
});
// reduce images for web
gulp.task ('images', function () {
return gulp.src(srcpaths.images)
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest(destpaths.images));
});
// reduce icons for web
gulp.task ('icons', function () {
return gulp.src(srcpaths.icons)
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest(destpaths.icons));
});
gulp.task('watch', function () {
gulp.watch(srcpaths.less, ['css']);
gulp.watch(srcpaths.icons, ['icons']);
gulp.watch(srcpaths.images, ['images']);
});
gulp.task('default', ['css', 'images', 'icons']);