forked from yogstation13/demo-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
49 lines (42 loc) · 1.27 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
'use strict';
var gulp = require('gulp');
//var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var less = require('gulp-less');
var concat = require('gulp-concat');
var log = require('gulplog');
var bundler = browserify({entries: './index.js', debug: true, cache: {}, packageCache: {}});
function bundle(used_bundler = bundler) {
return used_bundler.bundle()
.on('error', function(err) {
log.error(err.toString());
this.emit('end');
})
.pipe(source('out.js'))
.pipe(buffer())
//.pipe(sourcemaps.init({loadMaps: true}))
//.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./out/'));
}
gulp.task('js', function() {
return bundle();
});
gulp.task('css', function() {
return gulp.src("./css/**/*.less")
// .pipe(sourcemaps.init())
.pipe(less())
.pipe(concat('out.css'))
// .pipe(sourcemaps.write())
.pipe(gulp.dest('./out/'));
});
gulp.task('watch', function() {
bundler.plugin(watchify);
gulp.series('js')();
bundler.on('update', gulp.series('js'));
return gulp.watch(['css/**/*.less'], gulp.series('css'));
});
gulp.task('default', gulp.parallel('js', 'css'));
gulp.task('all', gulp.series('css', 'watch'));