-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
57 lines (48 loc) · 1.68 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
const gulp = require("gulp");
const sourcemaps = require("gulp-sourcemaps");
const babel = require("gulp-babel");
const concat = require("gulp-concat");
const uglify = require('gulp-uglify');
const uglifycss = require('gulp-uglifycss');
const sass = require('gulp-sass');
//ES6 plugins
const babelify = require('babelify');
const browserify = require('browserify');
const buffer = require('vinyl-buffer');
const source = require('vinyl-source-stream');
const ngAnnotate = require('gulp-ng-annotate');
//Scrips - Transpile all ES6 Javascript files
//==========================================
gulp.task("scripts", function () {
let bundler = browserify({
entries: 'src/app.js',
debug: true
});
bundler.transform(babelify);
bundler.bundle()
.on('error', (err) => console.error(err))
.pipe(source('all.min.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'));
});
// SASS - Compile and concat all Sass files
//==========================================
gulp.task("sass", function () {
return gulp.src(['src/**/*.scss'])
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(concat('all.min.css'))
.pipe(gulp.dest('dist'));
});
//Watch - Rerun the task when a file changes
//==========================================
gulp.task('watch', function() {
gulp.watch(["src/**/*.js", "!src/**/*.spec.js"], ['scripts']);
gulp.watch("src/**/*.spec.js", ['tests']);
gulp.watch("src/**/*.scss", ['sass']);
});
//default
gulp.task('default', ['watch', 'scripts', 'sass']);