-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathgulpfile.js
105 lines (84 loc) · 2.53 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* eslint prefer-arrow-callback: off */
import gulp from 'gulp';
import autoprefixer from 'gulp-autoprefixer';
import browserSyncBase from 'browser-sync';
import nodemon from 'gulp-nodemon';
import * as dartSass from 'sass';
import gulpSass from 'gulp-sass';
import sourcemaps from 'gulp-sourcemaps';
import uglifyBase from 'gulp-uglify-es';
const browserSync = browserSyncBase.create();
const sass = gulpSass(dartSass);
const uglify = uglifyBase.default;
gulp.task('build-css', function(done) {
gulp.src('source/scss/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(autoprefixer())
.pipe(sourcemaps.write('./sourcemaps'))
.pipe(gulp.dest('public/stylesheets'));
done();
});
gulp.task('build-js', function(done) {
gulp.src('source/js/*.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('./sourcemaps'))
.pipe(gulp.dest('public/javascripts'));
done();
});
gulp.task('build-js-utility', function(done) {
gulp.src('source/js/utility/*.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('./sourcemaps'))
.pipe(gulp.dest('public/javascripts/utility'));
done();
});
gulp.task('sync-css', gulp.series('build-css', function(done) {
browserSync.reload();
done();
}));
gulp.task('sync-js', gulp.series('build-js', function(done) {
browserSync.reload();
done();
}));
gulp.task('sync-js-utility', gulp.series('build-js-utility', function(done) {
browserSync.reload();
done();
}));
gulp.task('reload', function(done) {
browserSync.reload();
done();
});
gulp.task('nodemon', function(done) {
let started = false;
return nodemon({
script: './server.js',
ext: 'js pug',
ignore: [
'source/js',
'public/javascripts'
]
}).on('start', function() {
if (!started) {
started = true;
done();
}
});
});
gulp.task('watch', gulp.series('nodemon', function(done) {
browserSync.init({
proxy: `localhost:${process.env.DESCENT_PORT || 3000}/`,
port: 3333
});
gulp.watch('source/scss/*.scss', gulp.series('sync-css'));
gulp.watch('source/js/*.js', gulp.series('sync-js'));
gulp.watch('source/js/utility/*.js', gulp.series('sync-js-utility'));
gulp.watch('*.js', gulp.series('reload'));
gulp.watch('views/*.pug', gulp.series('reload'));
gulp.watch('views/template/*.pug', gulp.series('reload'));
done();
}));
gulp.task('build', gulp.series('build-css', 'build-js', 'build-js-utility'));
gulp.task('default', gulp.series('build', 'watch'));