-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
43 lines (38 loc) · 1.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
var gulp = require( 'gulp' );
var gutil = require( 'gulp-util' );
var source = require( 'vinyl-source-stream' );
var watchify = require( 'watchify' );
var browserify = require( 'browserify' );
var babelify = require( 'babelify' );
var webserver = require( 'gulp-webserver' );
var assign = require( 'object-assign' );
var bundler = watchify( browserify( './src/js/webplayer.js',
assign( watchify.args, { debug: true } ) ) ); //add inline sourcemap
// add any other browserify options or transforms here
bundler.transform( babelify.configure(
{
playground: true
} ) );
gulp.task( 'js', bundle ); // so you can run `gulp js` to build the file
gulp.task( 'serve', serve );
bundler.on( 'update', bundle ); // on any dep update, runs the bundler
bundler.on( 'log', gutil.log ); // output build logs to terminal
function bundle()
{
return bundler.bundle()
// log errors if they happen
.on( 'error', gutil.log.bind( gutil, 'Browserify Error' ) )
.pipe( source( 'webplayer.js' ) )
//
.pipe( gulp.dest( './dist/js/' ) );
}
function serve()
{
gulp.src( '.' )
.pipe( webserver(
{
livereload: true,
open: true,
fallback: 'index.html'
} ) );
}