-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
109 lines (93 loc) · 2.85 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
'use strict';
let gulp = require('gulp');
let path = require('path');
let $ = require('gulp-load-plugins')();
let del = require('del');
let runSequence = require('run-sequence');
let environment = $.util.env.type || 'development';
let isProduction = environment === 'production';
let webpackConfig = require('./webpack.config.js')[environment];
let deploy = require('./deploy');
let port = $.util.env.port || 8080;
let src = 'src/';
let dist = 'dist/';
let autoprefixerBrowsers = [
'ie >= 9',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 6',
'opera >= 23',
'ios >= 6',
'android >= 4.4',
'bb >= 10',
];
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
gulp.task('scripts', function () {
return gulp.src(webpackConfig.entry)
.pipe($.webpack(webpackConfig))
.pipe(isProduction ? $.uglifyjs() : $.util.noop())
.pipe(gulp.dest(dist + 'js/'))
.pipe($.size({ title: 'js' }))
.pipe($.connect.reload());
});
gulp.task('html', function () {
return gulp.src(src + 'index.html')
.pipe(gulp.dest(dist))
.pipe($.size({ title: 'html' }))
.pipe($.connect.reload());
});
gulp.task('styles', function () {
return gulp.src(src + 'less/**/*.less')
.pipe($.less())
.pipe($.concat('main.css'))
.pipe(isProduction ? $.cleanCss() : $.util.noop())
.pipe(gulp.dest(dist + 'css'))
.pipe($.size({ title: 'styles' }))
.pipe($.connect.reload());
});
gulp.task('serve', function () {
$.connect.server({
root: dist,
port: port,
livereload: {
port: 35728,
},
});
});
// gulp.task('static', function (cb) {
// return gulp.src(src + 'static/**/*')
// .pipe($.size({ title : 'static' }))
// .pipe(gulp.dest(dist + '/'));
// });
gulp.task('watch', function () {
gulp.watch(src + 'less/*.less', ['styles']);
gulp.watch(src + 'index.html', ['html']);
gulp.watch(src + 'app/**/*.js', ['scripts']);
gulp.watch(src + 'app/**/*.hbs', ['scripts']);
gulp.watch(src + 'app/**/*.handlebars', ['scripts']);
});
gulp.task('clean', function () {
return del([dist]);
});
// by default build project and then watch files in order to trigger livereload
gulp.task('default', function () {
return runSequence('build', ['serve', 'watch']);
});
// waits until clean is finished then builds the project
gulp.task('build', function () {
return runSequence('clean', ['html', 'scripts', 'styles']);
});
// todo: actually make synchronous, runsequence makes sub modules throw errors here
gulp.task('deploy', ['build'], function () {
let deployEnvironment = 'prod';
setTimeout(function () { deploy(deployEnvironment); }, 15000);
});
// gulp.task('deploy', ['build'], function () {
// return $.prompt.prompt({
// message: 'Enter deploy environment: dev or prod',
// default: 'dev',
// }, function (deployEnvironment) {
// setTimeout(function () { deploy(deployEnvironment); }, 10000);
// });
// });