-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGulpfile.js
97 lines (83 loc) · 2.33 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
var gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
server = require( 'gulp-develop-server' ),
livereload = require( 'gulp-livereload' ),
minifycss =require('gulp-minify-css'),
bower = require('gulp-bower');
var filesToMove = [
"./src/public/assets/**/*",
"./src/public/views/**/*",
"./src/public/js/vendor/*",
"./src/server/**/*",
"./src/index.js",
"./src/server/logs/"
];
var options = {
path: './build/index.js'
};
var serverFiles = [
'./build/index.js',
'./src/server/**/*.js',
'./build/server/**/*.js',
];
gulp.task('styles', function() {
gulp.src('src/public/styles/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(minifycss())
.pipe(gulp.dest('./build/public/styles/'));
});
gulp.task('minify', function() {
return gulp.src([
'src/public/js/_graphs.js',
'src/public/js/app.js'
])
.pipe(concat('app.min.js'))
.pipe(uglify({
compress: {
drop_console: true,
hoist_funs: false
}
}))
.pipe(gulp.dest('build/public/js/'));
});
gulp.task('move', function() {
gulp.src(filesToMove, { base: './src' })
.pipe(gulp.dest('build'));
});
gulp.task('bower_install', function() {
return bower();
});
gulp.task('watch-js', function() {
gulp.watch('src/public/js/*.js', ['minify']);
gulp.watch('src/public/styles/*.scss', ['minify']);
gulp.watch(filesToMove, ['move']);
});
// -- Tasks --------------------------------------------------------------------
gulp.task('watch', function() {
gulp.watch('./src/public/js/*.js', ['minify']);
gulp.watch('./src/public/styles/*.scss', ['styles']);
gulp.watch(filesToMove, ['move']);
return;
});
gulp.task('build', ['watch'], function() {
gulp.start(['minify', 'styles', 'move']);
return;
});
// -- Run ----------------------------------------------------------------------
gulp.task( 'server:start', ['build', 'minify', 'styles', 'move'], function() {
server.listen( options, livereload.listen );
});
gulp.task( 'default', ['server:start'], function() {
function restart( file ) {
server.changed( function( error ) {
if( ! error ) livereload.changed( file.path );
});
}
gulp.watch(serverFiles).on( 'change', restart );
});
gulp.task('bower', function() {
gulp.start(['bower_install']);
return;
});