-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
51 lines (45 loc) · 1.74 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
var gulp = require('gulp'),
watch = require('gulp-watch'),
less = require('gulp-less'),
cleanCSS = require('gulp-clean-css'),
plumber = require('gulp-plumber'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
babel = require('gulp-babel');
// root folder for all styles
var paths = {
webroot: "./"
};
// less folder within root
paths.less = paths.webroot + "styles/less/*.less";
paths.js = {
config: paths.webroot + "scripts/config/config.js",
controllers: paths.webroot + "scripts/controllers/*.js",
directives: paths.webroot + "scripts/directives/*.js",
services: paths.webroot + "scripts/services/*.js",
app: paths.webroot + "scripts/app.js"
};
// compile less files, concat into single css file and minify
gulp.task('less-common', function () {
return gulp.src(['!./styles/less/typography.less', paths.less])
.pipe(plumber())
.pipe(less())
.pipe(cleanCSS())
.pipe(concat('styles.min.css'))
.pipe(gulp.dest(paths.webroot + "styles"));
});
gulp.task('compress', function () {
return gulp.src([paths.js.config, paths.js.controllers, paths.js.directives, paths.js.services, paths.js.app])
.pipe(plumber())
.pipe(babel({ presets: ['es2015'] }))
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(gulp.dest(paths.webroot + "scripts/compressed"));
});
// watch less task for changes
gulp.task('watch', function () {
gulp.watch(paths.less, ['less-common']);
gulp.watch([paths.js.config, paths.js.controllers, paths.js.directives, paths.js.services, paths.js.app], ['compress']);
});
// default task
gulp.task('default', ['less-common', 'compress', 'watch']);