This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (47 loc) · 1.54 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
const config = require("./config.js");
const gulp = require("gulp");
const plumber = require("gulp-plumber");
const sourcemaps = require("gulp-sourcemaps");
const browsersync = require("browser-sync");
const sass = require("gulp-sass");
const postcss = require("gulp-postcss");
const scss = require("postcss-scss");
const reporter = require("postcss-reporter");
const precss = require("precss");
const autoprefixer = require("autoprefixer");
const stylelint = require("stylelint");
const stylefmt = require("gulp-stylefmt");
gulp.task("default", ["watch"], function() { });
gulp.task("watch", ["browsersync"], function() { });
gulp.task("browsersync", function() {
browsersync(config.browsersync);
gulp.watch("*.{sass,scss}", ["sass"]);
gulp.watch("*.{css,html,js}", browsersync.reload);
});
gulp.task("sass", function() {
const processors = [
precss(config.precss.options),
autoprefixer(config.autoprefixer.options)
];
return gulp.src("main.scss")
.pipe(sourcemaps.init())
.pipe(sass.sync().on("error", sass.logError))
.pipe(postcss(processors, {syntax: scss}))
.pipe(sourcemaps.write("maps"))
.pipe(gulp.dest(config.sass.dest))
.pipe(browsersync.stream());
});
gulp.task("stylelint", function() {
const processors = [
stylelint(config.stylelint),
reporter(config.reporter)
];
return gulp.src(config.stylelint.src)
.pipe(plumber())
.pipe(postcss(processors, {syntax: scss}))
});
gulp.task("stylefmt", function () {
return gulp.src(config.stylefmt.src)
.pipe(stylefmt(config.stylelint))
.pipe(gulp.dest(config.stylefmt.dest));
});