This repository has been archived by the owner on Feb 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
76 lines (68 loc) · 1.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
require('dotenv/config');
const gulp = require('gulp');
const minifyCss = require('gulp-clean-css');
const concat = require('gulp-concat');
const ngAnnotate = require('gulp-ng-annotate');
const nodemon = require('gulp-nodemon');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
const babel = require('gulp-babel');
function swallowError(error) {
// If you want details of the error in the console
console.log(error.toString());
this.emit('end');
}
gulp.task('default', () => {
console.log('yo. use gulp watch or something');
});
gulp.task('js', () => {
if (process.env.NODE_ENV !== 'dev') {
// Minify for non-development
gulp.src(['app/client/src/**/*.js', 'app/client/views/**/*.js'])
.pipe(sourcemaps.init())
.pipe(concat('app.js'))
.pipe(ngAnnotate())
.on('error', swallowError)
.pipe(babel())
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('app/client/build'));
} else {
gulp.src(['app/client/src/**/*.js', 'app/client/views/**/*.js'])
.pipe(sourcemaps.init())
.pipe(concat('app.js'))
.pipe(ngAnnotate())
.on('error', swallowError)
.pipe(babel())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('app/client/build'));
}
});
gulp.task('sass', () => {
gulp.src('app/client/stylesheets/site.scss')
.pipe(sass())
.on('error', sass.logError)
.pipe(minifyCss())
.pipe(gulp.dest('app/client/build'));
});
gulp.task('build', ['js', 'sass'], () => {
// Yup, build the js and sass.
});
gulp.task('watch', ['js', 'sass'], () => {
gulp
.watch('app/client/src/**/*.js', ['js']);
gulp
.watch('app/client/views/**/*.js', ['js']);
gulp
.watch('app/client/stylesheets/**/*.scss', ['sass']);
});
gulp.task('server', ['watch'], () => {
nodemon({
script: 'app.js',
env: { 'NODE_ENV': process.env.NODE_ENV || 'DEV' },
watch: [
'app/server'
]
});
});