forked from zurb/tribute
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
77 lines (66 loc) · 1.89 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
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');
var webserver = require('gulp-webserver');
var opn = require('opn');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var babelify = require('babelify');
var uglify = require('gulp-uglifyjs');
var sourcePaths = {
styles: ['scss/**/*.scss'],
src: ['src/**/*.js']
};
var distPaths = {
styles: 'dist',
js: 'dist'
};
var server = {
host: 'localhost',
port: '8001'
}
gulp.task('uglify', ['bundler'], function() {
gulp.src('dist/tribute.js')
.pipe(uglify('tribute.min.js', {
outSourceMap: true
}))
.pipe(gulp.dest('dist'))
});
// Basic usage
gulp.task('bundler', function() {
// Single entry point to browserify
return browserify('src/index.js', {
debug: true, standalone: "Tribute"
})
.transform(babelify)
.bundle()
.on('error', function(err) {
console.log('Error: ' + err.message);
})
.pipe(source('tribute.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('sass', function() {
gulp.src(sourcePaths.styles)
.pipe(plumber())
.pipe(sass())
.pipe(gulp.dest(distPaths.styles));
});
gulp.task('webserver', function() {
gulp.src('.')
.pipe(webserver({
host: server.host,
port: server.port,
livereload: false,
directoryListing: false
}));
});
gulp.task('openbrowser', ['build'], function() {
opn('http://' + server.host + ':' + server.port + '/example/index.html');
});
gulp.task('watch', function() {
gulp.watch(sourcePaths.styles, ['sass']);
gulp.watch(sourcePaths.src, ['bundler']);
});
gulp.task('build', ['sass', 'uglify']);
gulp.task('default', ['build', 'webserver', 'watch', 'openbrowser']);