-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
70 lines (62 loc) · 1.6 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var csso = require('gulp-csso');
var uglify = require('gulp-uglify-es').default;
var autoprefixer = require('gulp-autoprefixer');
var header = require('gulp-header');
var babel = require('gulp-babel');
gulp.task('js', function(){
return gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(concat('sffilesystem.min.js'))
.pipe(babel({
"presets": [
[
"@babel/preset-env",
{
"targets": {
"ie": "9"
},
"loose":true,
"modules": false
}
]
]
}))
.on('error', swallowError)
.pipe(uglify())
.on('error', swallowError)
.pipe(header(`/*
SFFileSystem
A library for accessing local file system for
the current website on the browser
https://github.com/ScarletsFiction/SFFileSystem
*/\n`))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'));
});
gulp.task('watch', function() {
gulp.watch(['src/**/*.js'], ['js']);
});
gulp.task('serve', function() {
browserSync({
server: {
baseDir: 'example'
}
});
gulp.watch(['*.html', 'scripts/**/*.js'], {cwd: 'example'}, reload);
});
gulp.task('css', function () {
return gulp.src('src/**/*.css')
.pipe(autoprefixer({browsers: AUTOPREFIXER_BROWSERS}))
.pipe(csso())
.pipe(gulp.dest('./dist/css'))
});
gulp.task('default', ['js']);
function swallowError(error){
console.log(error.message)
this.emit('end')
}