-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathgulpfile.js
63 lines (51 loc) · 1.47 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
const chalk = require('chalk');
const fs = require('fs-extra');
const gulp = require('gulp');
const sass = require('gulp-dart-sass');
/********************/
/* CONFIGURATION */
/********************/
const name = 'foundryvtt-devMode';
const sourceDirectory = '.';
const distDirectory = './';
const stylesDirectory = `${sourceDirectory}/styles`;
const stylesExtension = 'scss';
/********************/
/* BUILD */
/********************/
/**
* Build style sheets
*/
function buildStyles() {
return gulp
.src(`${stylesDirectory}/${name}.${stylesExtension}`)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(`${distDirectory}`));
}
/**
* Watch for changes for each build step
*/
function buildWatch() {
gulp.watch(`${stylesDirectory}/**/*.${stylesExtension}`, { ignoreInitial: false }, buildStyles);
}
/********************/
/* CLEAN */
/********************/
/**
* Remove built files from `dist` folder while ignoring source files
*/
async function clean() {
const files = [];
if (fs.existsSync(`${stylesDirectory}/${name}.${stylesExtension}`)) {
files.push(`${name}.css`);
}
console.log(' ', chalk.yellow('Files to clean:'));
console.log(' ', chalk.blueBright(files.join('\n ')));
for (const filePath of files) {
await fs.remove(`${distDirectory}/${filePath}`);
}
}
const execBuild = gulp.parallel(buildStyles);
exports.build = gulp.series(clean, execBuild);
exports.watch = buildWatch;
exports.clean = clean;