forked from duo-labs/webauthn.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
86 lines (68 loc) · 2.22 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
var gulp = require('gulp');
var through2 = require('through2');
var log = require('fancy-log');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var sassInput = './static/src/scss/*.scss';
var sassOutput = './static/dist/css/';
var imagesInput = './static/src/images/*';
var imagesOutput = './static/dist/images/';
var fontsInput = "./static/src/fonts/**/*";
var fontsOutput = "./static/dist/fonts/"
var autoprefixerOptions = {
browsers: ['last 2 versions', '> 5%', 'Firefox ESR']
};
const isProd = process.env.NODE_ENV === 'production';
var sassOptions = {
errLogToConsole: true,
outputStyle: isProd ? 'compressed' : 'expanded'
};
gulp.task('sass', function () {
return gulp
.src(sassInput)
.pipe(isProd ? () => through2.obj() : sourcemaps.init())
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(isProd ? () => through2.obj() : sourcemaps.write())
.pipe(autoprefixer(autoprefixerOptions))
.pipe(gulp.dest(sassOutput))
});
gulp.task('images', () => {
return gulp
.src(imagesInput)
.pipe(gulp.dest(imagesOutput))
});
gulp.task('fonts', () => {
return gulp
.src(fontsInput)
.pipe(gulp.dest(fontsOutput))
});
gulp.task('sass-watch', function () {
return gulp
// Watch the input folder for change,
// and run `sass` task when something happens
.watch(sassInput, ['sass'])
// When there is a change,
// log a message in the console
.on('change', function (event) {
log('File ' + event.path + ' was ' + event.type + ', running tasks...');
});
});
gulp.task('images-watch', ['images'], () => {
return gulp
.watch(imagesInput, ['images'])
.on('change', event => {
log(`File ${event.path} was ${event.type}`);
})
})
gulp.task('watch', ['sass-watch', 'images-watch', 'fonts']);
gulp.task('build', ['sass', 'images', 'fonts']);
gulp.task('prod', function () {
return gulp
.src(sassInput)
.pipe(sass({
outputStyle: 'compressed'
}))
.pipe(autoprefixer(autoprefixerOptions))
.pipe(gulp.dest(sassOutput));
});