/
gulpfile.js
62 lines (52 loc) · 1.65 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
// Modules
var gulp = require('gulp');
var pug = require('gulp-pug');
var less = require('gulp-less');
var browserSync = require('browser-sync').create();
var source = require('vinyl-source-stream');
var browserify = require('browserify');
// Tasks
gulp.task('default', ['pug', 'less', 'browserify', 'browserifyRelease']);
gulp.task('pug', function(){
return gulp.src( './src/pug/**/*.pug')
.pipe( pug( {pretty: true}))
.pipe( gulp.dest('./docs/'));
});
gulp.task('less', function(){
return gulp.src( './src/less/**/*.less')
.pipe( less())
.pipe( gulp.dest('./docs/'));
});
gulp.task('browserify', function() {
return browserify('./src/js/main.js')
.bundle()
//Pass desired output filename to vinyl-source-stream
.pipe(source('build.js'))
// Start piping stream to tasks!
.pipe(gulp.dest('./docs/'));
});
gulp.task('browserifyRelease', function() {
return browserify('./src/js/mainForRelease.js')
.bundle()
//Pass desired output filename to vinyl-source-stream
.pipe(source('buildForRelease.js'))
// Start piping stream to tasks!
.pipe(gulp.dest('./docs/'));
});
// Watching
gulp.task('watch', function(){
browserSync.init({
port: 4000, //where is browser sync
proxy: 'http://localhost:3000/', //what are we proxying?
ui: {port: 4001}, //where is the UI
browser: [] //empty array of browsers
});
gulp.watch('./src/pug/**/*.pug', [ 'pug'])
.on('change', browserSync.reload);
gulp.watch('./src/less/**/*.less', [ 'less'])
.on('change', browserSync.reload);
gulp.watch('./src/js/**/*.js', [ 'browserify'])
.on('change', browserSync.reload);
gulp.watch('./src/js/**/*.js', [ 'browserifyRelease'])
.on('change', browserSync.reload);
});