This repository has been archived by the owner on Apr 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (60 loc) · 1.72 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
const fs = require('fs'),
gulp = require('gulp'),
sass = require('gulp-sass'),
rename = require('gulp-rename'),
terser = require('gulp-terser'),
replace = require('gulp-replace'),
browserify = require('browserify'),
buffer = require('vinyl-buffer'),
source = require('vinyl-source-stream');
/**
* CSS Tasks
*/
gulp.task('css', () => {
return gulp.src('./assets/scss/main.scss')
.pipe(sass({
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(rename('app.css'))
.pipe(gulp.dest('./dist/css'))
});
gulp.task('css:watch', () => {
return gulp.watch('./assets/scss/**', gulp.series('css'));
});
/**
* JS Tasks
*/
gulp.task('js', () => {
// Get Mapbox access token
var token = fs.readFileSync(__dirname + '/.mapbox-token', 'utf-8', 'r').toString().replace('\n', '');
var b = browserify({
entries: './assets/js/app.js',
});
// Task process
return b.bundle()
.pipe(source('app.js'))
.pipe(replace('replaced-mapbox-access-token', token))
.pipe(buffer())
.pipe(terser())
.pipe(gulp.dest('./dist/js/'));
});
gulp.task('js:watch', () => {
return gulp.watch('./assets/js/**', gulp.series('js'));
});
/**
* Images and fonts tasks
*/
gulp.task('images', () => {
return gulp.src('./assets/images/**')
.pipe(gulp.dest('./dist/images/'));
});
gulp.task('fonts', () => {
return gulp.src('./assets/fonts/**')
.pipe(gulp.dest('./dist/fonts/'));
});
/**
* General and default tasks
*/
gulp.task('all', gulp.series('css', 'js', 'images', 'fonts'));
gulp.task('all:watch', gulp.parallel('css:watch', 'js:watch'));
gulp.task('default', gulp.series('all'));