-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
74 lines (65 loc) · 1.91 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
minifycss = require('gulp-minify-css'),
//uglify = require('gulp-uglify'),
//source = require('vinyl-source-stream'),
//buffer = require('vinyl-buffer'),
//sourcemaps = require('gulp-sourcemaps'),
browserify = require('browserify'),
transform = require('vinyl-transform'),
livereload = require('gulp-livereload'),
del = require('del'),
paths = {
scriptsSrc: './app/**/*.js',
scriptsDest: './www/build/js',
stylesSrc: './www/res/scss/**/*.scss',
stylesDest: './www/build/css',
html: 'www/**/*.html'
};
// Styles
gulp.task('styles', function() {
return gulp.src(paths.stylesSrc)
.pipe(sass())
.pipe(minifycss())
.pipe(gulp.dest(paths.stylesDest));
});
// Browserify task
gulp.task('browserify', function () {
var browserified = transform(function(filename) {
return browserify(filename)
.require(filename, { expose: 'app'})
.bundle()
//.pipe(source('./app.min.js'))
//.pipe(buffer())
//.pipe(sourcemaps.init({loadMaps: true}))
//.pipe(uglify())
//.pipe(sourcemaps.write('./'));
});
return gulp.src('./app/app.main.js')
.pipe(browserified)
.pipe(gulp.dest(paths.scriptsDest));
});
// Scripts task
gulp.task('scripts', ['browserify']);
// Clean task
gulp.task('clean', function(cb) {
del([
paths.stylesDest,
paths.scriptsDest
], cb);
});
// Watch task
gulp.task('watch', function() {
livereload.listen();
gulp.watch(paths.stylesSrc, ['styles']);
gulp.watch(paths.scriptsSrc, ['scripts']);
gulp.watch([
paths.scriptsSrc,
paths.stylesSrc,
paths.html
]).on('change', livereload.changed);
});
// Default task
gulp.task('default', ['clean'], function() {
gulp.start('styles', 'scripts');
});