forked from youmustfight/vr_app_landing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
111 lines (90 loc) · 2.98 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Gulp Modules
var gulp = require('gulp');
var babel = require('gulp-babel');
var runSeq = require('run-sequence');
var plumber = require('gulp-plumber');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var minifyCSS = require('gulp-minify-css');
var ngAnnotate = require('gulp-ng-annotate');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var livereload = require('gulp-livereload');
var fileinclude = require('gulp-file-include');
// --------------------------------------------------------------
// Development tasks
// --------------------------------------------------------------
// Live reload business.
gulp.task('reload', function () {
livereload.reload();
});
gulp.task('reloadCSS', function () {
return gulp.src('./public/style.css').pipe(livereload());
});
gulp.task('buildJS', function () {
return gulp.src(['./app/js/app.js', './app/js/**/*.js'])
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(concat('main.js'))
// .pipe(babel())
.pipe(sourcemaps.write())
.pipe(gulp.dest('./public'));
});
gulp.task('buildCSS', function () {
return gulp.src('./app/scss/main.scss')
.pipe(sass({
errLogToConsole: true
}))
.pipe(rename('style.css'))
.pipe(gulp.dest('./public'));
});
gulp.task('buildHTML', function(){
return gulp.src(['./app/html/main.html'])
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(rename('index.html'))
.pipe(gulp.dest('./'))
});
// --------------------------------------------------------------
// Production tasks
// --------------------------------------------------------------
gulp.task('buildCSSProduction', function () {
return gulp.src('./app/scss/main.scss')
.pipe(sass())
.pipe(rename('style.css'))
.pipe(minifyCSS())
.pipe(gulp.dest('./public'))
});
gulp.task('buildJSProduction', function () {
return gulp.src(['./app/js/app.js', './app/js/**/*.js'])
.pipe(concat('main.js'))
// .pipe(babel())
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(gulp.dest('./public'));
});
gulp.task('buildProduction', ['buildCSSProduction', 'buildJSProduction', 'buildHTML']);
// --------------------------------------------------------------
// Composed tasks
// --------------------------------------------------------------
gulp.task('build', function () {
runSeq(['buildJS', 'buildCSS', 'buildHTML']);
// runSeq('buildProduction');
});
gulp.task('default', function () {
livereload.listen();
gulp.start('build');
gulp.watch('app/js/**', function () {
runSeq('buildJS', 'reload');
});
gulp.watch('app/scss/**', function () {
runSeq('buildCSS', 'reloadCSS');
});
// Reload when a template (.html) file changes.
gulp.watch(['app/**/*.html'], function() {
runSeq('buildHTML', 'reload');
});
});