-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.mjs
70 lines (53 loc) · 1.5 KB
/
gulpfile.mjs
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
'use strict';
// TODO clean up some more using https://github.com/gulpjs/gulp#use-latest-javascript-version-in-your-gulpfile
import gulp from 'gulp';
import dartSass from 'sass-embedded';
import gulpSass from 'gulp-sass';
const sass = gulpSass(dartSass);
import sourcemaps from 'gulp-sourcemaps';
import { deleteAsync } from 'del';
import cleanCSS from 'gulp-clean-css';
import concat from 'gulp-concat';
// Future: gulp-imagemin, gulp-copy
// General
var assetDest = "themes/phenix/assets";
function clean() {
return deleteAsync([
assetDest + '/styles/*',
assetDest + '/js/*',
]);
};
// Styles
var sassSrc = "./bits/styles/**/*.scss";
var assetDest = "themes/phenix/assets";
var cssDest = assetDest + "/styles";
export function buildStyles() {
return gulp.src(sassSrc)
.pipe(sourcemaps.init())
.pipe(sass.sync({
outputStyle: 'compressed',
includePaths: ['node_modules/normalize.css']
}).on('error', sass.logError))
.pipe(cleanCSS())
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest(cssDest));
};
// JavaScript
var jsSrc = "./bits/**/*.js";
var jsDest = assetDest + "/js";
export function buildScripts() {
return gulp.src(jsSrc)
.pipe(concat('scripts.js'))
.pipe(gulp.dest(jsDest));
};
// Main
function watchFiles() {
gulp.watch(sassSrc, buildStyles);
gulp.watch(jsSrc, buildScripts);
};
export { watchFiles as watch };
const build = gulp.series(clean, gulp.parallel(buildStyles, buildScripts));
/*
* Export a default task
*/
export default build;