-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
78 lines (66 loc) · 1.86 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
const gulp = require('gulp');
const browserify = require('gulp-browserify');
const rename = require('gulp-rename');
const plumber = require('gulp-plumber');
const sass = require('gulp-sass');
const minify = require("gulp-minify-css");
const browserSync = require('browser-sync');
const flatten = require('gulp-flatten');
var browserSyncSettings = {
proxy: {
target: "localhost:3000"
}
}
var jsPath = ["./wwwsrc/js/*/*.js"];
var jsBuildPath = "./wwwbuild/js/";
var jsWatchPath = ["./wwwsrc/js/**/*"];
var scssPath = ["./wwwsrc/scss/*/[^_]*.scss"];
var scssBuildPath = "./wwwbuild/scss/";
var scssWatchPath = ["./wwwsrc/scss/**/*"];
function reload(){
if (typeof browserSyncSettings != "undefined")
browserSync.reload();
}
//Build App JS -> Output to JS/.min
gulp.task('js', function(cb) {
gulp.src(jsPath)
.pipe(plumber())
.pipe(browserify({
insertGlobals: true
}))
.pipe(flatten())
.pipe(gulp.dest(jsBuildPath))
.on('finish', function(){
reload();
cb();
});
});
//Combile SASS -> Output to CSS/.min
gulp.task('scss', function(cb) {
gulp.src(scssPath)
.pipe(sass().on('error', sass.logError))
.pipe(flatten())
.pipe(gulp.dest(scssBuildPath))
.pipe(minify({compatibility: 'ie8'}))
.pipe(rename({
extname: '.min.css'
}))
.pipe(gulp.dest(scssBuildPath))
.on('finish', function(){
reload();
cb();
});
});
gulp.task('watch', function(cb){
gulp.watch(jsWatchPath, ['js'])
gulp.watch(scssWatchPath, ['scss'])
cb();
});
gulp.task('browsersync', function(cb){
if (browserSyncSettings)
browserSync(browserSyncSettings);
cb();
});
// The default task
gulp.task('build', ['scss', 'js']);
gulp.task('default', ['build', 'browsersync', 'watch']);