-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.ts
71 lines (64 loc) · 1.87 KB
/
gulpfile.ts
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
import browserSync from "browser-sync";
import gulp from "gulp";
import autoprefixer from "gulp-autoprefixer";
import eslint from "gulp-eslint-new";
import sassFactory from "gulp-sass";
import stylelint from "gulp-stylelint";
import * as sassCompiler from "sass-embedded";
const sass = sassFactory(sassCompiler);
const jsSrc = "public/editor/js/**/*.js";
const lintJS = () =>
{
return gulp.src(jsSrc)
.pipe(eslint())
.pipe(eslint.format());
};
gulp.task("lint_js", lintJS);
const prefixerOptions: autoprefixer.Options =
{
flexbox: "no-2009"
};
const sassSrc = "public/editor/sass/**/*.scss";
const sassDest = "public/editor/css/";
const lintSass = () =>
{
return gulp.src(sassSrc)
.pipe(stylelint(
{
failAfterError: false,
reporters: [{ formatter: "string", console: true }]
}));
};
gulp.task("lint_sass", lintSass);
const compileSass = () =>
{
return gulp.src(sassSrc, { sourcemaps: true })
.pipe(sass().on("error", sass.logError))
.pipe(autoprefixer(prefixerOptions))
.pipe(gulp.dest(sassDest, { sourcemaps: '.' }));
};
const processSass = gulp.series(lintSass, compileSass);
gulp.task("sass", processSass);
const watch = (done, browserSyncInstance?: browserSync.BrowserSyncInstance) =>
{
gulp.watch(jsSrc, lintJS);
gulp.watch(
sassSrc,
gulp.series(lintSass, browserSyncInstance ? () => compileSass().pipe(browserSyncInstance.stream()) : compileSass)
);
console.log("Watching for file changes...");
done();
};
gulp.task("watch", watch);
gulp.task("stream", (done) =>
{
const browserSyncInstance = browserSync.create();
browserSyncInstance.init(
{
proxy: "http://localhost"
});
watch(done, browserSyncInstance);
});
const build = gulp.parallel(lintJS, processSass);
gulp.task("build", build);
gulp.task("default", gulp.series(build, watch));