-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (50 loc) · 1.37 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
const gulp = require('gulp');
const concat = require('gulp-concat');
const sort = require('sort-stream');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
const ngAnnotate = require('gulp-ng-annotate');
const path = require('path');
const babel = require('gulp-babel');
const eslint = require('gulp-eslint');
const paths = {
scripts: './app/**/*.js',
styles: ['./css/**/*.css', './app/**/*.css', './app/**/*.scss'],
images: './images/**/*',
index: './app/index.html',
partials: ['./app/**/*.html', '!app/index.html'],
dist: './dist'
};
const fileOrder = (a, b) => {
aScore = a.path.includes("module.js") ? 1 : 0;
bScore = b.path.includes("module.js") ? 1 : 0;
return bScore - aScore;
}
gulp.task('default', ['dev', 'watch']);
gulp.task('watch', () => gulp.watch(paths.scripts, ['dev']))
gulp.task('dev', () => {
gulp.src(paths.scripts)
.pipe(eslint())
.pipe(eslint.format())
// .pipe(eslint.failAfterError())
.pipe(babel({
presets: ['env']
}))
.pipe(sort(fileOrder))
.pipe(sourcemaps.init())
.pipe(concat("app.js"))
.pipe(ngAnnotate())
.pipe(gulp.dest(paths.dist));
});
gulp.task('build', () => {
gulp.src(paths.scripts)
.pipe(babel({
presets: ['env']
}))
.pipe(sort(fileOrder))
.pipe(sourcemaps.init())
.pipe(concat("app.js"))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(gulp.dest(paths.dist));
});