-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
69 lines (59 loc) · 1.84 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
var gulp = require('gulp');
var path = require('path');
var del = require('del');
var $ = require('gulp-load-plugins')({
pattern: '*',
});
var environments = ['development', 'production'];
var environment = environments.indexOf($.util.env.t) > -1 ? $.util.env.t : 'development';
var isProduction = (environment === 'production');
var webpackConfig = require('./webpack.config.js')[environment];
var port = $.util.env.p || 9001;
var src = 'web/app/';
var dist = 'web/public/';
gulp.task('scripts', function() {
return gulp.src(webpackConfig.entry.app)
.pipe($.webpackStream(webpackConfig))
.pipe(isProduction ? $.uglify({preserveComments: 'license'}) : $.util.noop())
.pipe(isProduction ? $.stripDebug() : $.util.noop())
.pipe(gulp.dest(dist))
.pipe($.size({
title: 'js'
}))
.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 + 'assets/**/*')
.pipe($.size({
title: 'static'
}))
.pipe(gulp.dest(dist + 'assets/'));
});
gulp.task('watch', function() {
gulp.watch(src + 'assets/**/*', ['static']);
gulp.watch(src + '**/*.js', ['scripts']);
gulp.watch(src + '**/*.hbs', ['scripts']);
gulp.watch(src + '**/*.json', ['scripts']);
gulp.watch(src + '**/*.css', ['scripts']);
});
gulp.task('clean', function(cb) {
del([dist]).then(function() {
cb();
});
});
var defaultTasks = ['static', 'scripts'];
// waits until clean is finished then builds the project
gulp.task('build', ['clean'], function() {
gulp.start(defaultTasks);
});
// by default build project and then watch files
gulp.task('default', ['build', 'serve', 'watch']);