-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
57 lines (52 loc) · 1.39 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
const gulp = require('gulp');
const babel = require('gulp-babel');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const webserver = require('gulp-webserver');
const watch = require('gulp-watch');
const browserify = require('gulp-browserify');
const sourcemaps = require('gulp-sourcemaps');
gulp.task('build', () => {
gulp.src('src/Magnet.js')
.pipe(browserify({
insertGlobals : true,
debug : true
}))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(concat('magnet.min.js'))
.pipe(babel({
presets: ["env", "stage-2", "stage-0"]
}))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
});
gulp.task('server', () => {
return gulp.src(['example/html','dist'])
.pipe(webserver({
fallback: 'index.html',
path: '/',
livereload: true,
directoryListing: false,
open: true
}));
})
gulp.task('watch', () => {
return watch('src/**/*', function () {
gulp.src('src/Magnet.js')
.pipe(browserify({
insertGlobals : true,
debug : true
}))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(concat('magnet.min.js'))
.pipe(babel({
presets: ["env", "stage-2", "stage-0"]
}))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
});
});
gulp.task('dev', ['build','watch','server'])
gulp.task('default', ['build'] );