-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathgulpfile.js
52 lines (44 loc) · 1.24 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
const gulp = require('gulp');
const less = require('gulp-less');
const cleanCss = require('gulp-clean-css');
const path = require('path');
const fs = require('fs');
gulp.task('clean-out', function (cb) {
// Delete ./out folder
if (fs.existsSync('./out')) {
fs.rmdirSync('./out', { recursive: true });
}
cb();
});
gulp.task('compile-less', function (cb) {
// 1. Compile all *.less files in ./styles
gulp
.src('./styles/**/*.less')
.pipe(
less({
paths: [
path.join(__dirname, 'styles'),
path.join(__dirname, 'styles/preview_theme'),
path.join(__dirname, 'styles/prism_theme'),
],
}),
)
.pipe(cleanCss())
.pipe(gulp.dest('./out/styles'));
// 2. Copy all files except *.less in ./styles to ./out/styles
gulp
.src(['./styles/**/*', '!./styles/**/*.less'])
.pipe(cleanCss())
.pipe(gulp.dest('./out/styles'));
cb();
});
// Whenever there is a change in ./styles, run 'compile-less' task
gulp.task('watch-less', function (cb) {
gulp.watch('./styles/**/*', gulp.series('compile-less'));
cb();
});
gulp.task('copy-files', function (cb) {
// Copy ./dependencies to ./out
gulp.src('./dependencies/**/*').pipe(gulp.dest('./out/dependencies'));
cb();
});