-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgulpfile.js
45 lines (40 loc) · 1.05 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
var gulp = require("gulp");
var rename = require("gulp-rename");
var postcss = require('gulp-postcss');
var svg = function (css, opts) {
css.replaceValues(/\bsvg\s*\([\S\s]+?'\)/g, {
fast: "svg",
props: ["background", "background-image", "content"]
}, string => {
return string.replace(/\bsvg\s*\((\d+), (\d+), '/, `url('data:image/svg+xml,
<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox="0 0 $1 $2">
`)
.replace(/'\)$/, `
</svg>')`)
.replace(/\n/g, "\\\n");
});
};
gulp.task('css', function () {
return gulp.src(["**/*.src.css", "!node_modules/**"])
.pipe(postcss([
require('postcss-nesting')(),
require("postcss-selector-matches")({
lineBreak: true
}),
require('autoprefixer')({
browsers: ["last 2 versions"]
}),
require("postcss-custom-properties")({
preserve: false,
warnings: false
}),
svg
]))
.pipe(rename({ extname: "" }))
.pipe(rename({ extname: ".css" }))
.pipe(gulp.dest('.'));
});
gulp.task("watch", function() {
gulp.watch(["**/*.src.css"], ["css"]);
});
gulp.task("default", ["css"]);