-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
78 lines (66 loc) · 1.79 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
71
72
73
74
75
76
77
78
var browserify = require('gulp-browserify'),
concat = require('gulp-concat'),
connect = require('gulp-connect'),
gulp = require('gulp'),
open = require('gulp-open'),
babel = require("gulp-babel"),
plumber = require('gulp-plumber'),
babelify = require('babelify'),
livereload = require('gulp-livereload');
gulp
// performs magic
.task('browserify', function(){
gulp.src('src/js/main.js')
.pipe(plumber())
.pipe(
browserify({
transform: 'babelify',
debug: false //!gulp.env.production
})
)
.pipe(concat('main.js'))
.pipe(plumber.stop())
.pipe(gulp.dest('dist/js'))
.pipe(livereload());
})
// moves source files to dist
.task('copy', function(){
gulp
.src('src/index.html')
.pipe(gulp.dest('dist'));
gulp
.src('src/assets/**/*.*')
.pipe(gulp.dest('dist/assets'));
gulp
.src('src/img/**/*.*')
.pipe(gulp.dest('dist/img'));
})
// local development server
.task('connect', function(){
connect.server({
root: ['dist'],
port: '8081',
base: 'http://localhost',
fallback: "dist/index.html",
livereload: true
});
})
//opens the application in chrome
.task('open', function(){
gulp
.src('dist/index.html')
.pipe(
open('', {app: 'google chrome',url: 'http://localhost:8080/'})
);
})
// build the application
.task('default', ['browserify', 'copy', 'connect', 'open'])
.task('default2', ['browserify', 'copy'])
.task('watch2', ['default2'], function () {
gulp.watch('src/**/*.*', ['default2']);
})
// watch for source changes
.task('watch', ['default'], function(){
livereload.listen();
gulp.watch('src/**/*.*', ['default2']);
});