-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
72 lines (61 loc) · 2.17 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
// Require gulp
const gulp = require('gulp');
// Require plugins
const sass = require('gulp-sass');
const babel = require('gulp-babel');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const concatCss = require('gulp-concat-css');
const minifyCss = require('gulp-minify-css');
gulp.task('sass', () => {
return gulp.src(['./assets/sass/main.scss'])
.pipe(sass({
outputStyle: 'expanded'
}).on('error', sass.logError))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./public/css'));
});
gulp.task('scripts', () => {
return gulp.src(['./assets/js/*.js'])
.pipe(concat('main.min.js'))
.pipe(babel({
presets: [
[
'es2015',
{ modules: false }
]
]
}))
.pipe(gulp.dest('./public/js'));
});
gulp.task('vendor-js', () => {
return gulp.src(['./assets/js/vendor/jquery.js', './assets/js/vendor/bootstrap.js', './assets/js/vendor/*.js'])
.pipe(concat('vendor.min.js'))
.pipe(gulp.dest('./public/js'));
});
gulp.task('vendor-css', () => {
return gulp.src(['./assets/css/vendor/bootstrap.css', './assets/css/vendor/*.css'])
.pipe(concatCss('vendor.min.css'))
.pipe(gulp.dest('./public/css'));
});
gulp.task('minify-js', ['scripts', 'vendor-js'], () => {
return gulp.src(['./public/js/**/*.js'])
.pipe(uglify())
.pipe(gulp.dest('./public/js'));
});
gulp.task('minify-css', ['sass', 'vendor-css'], () => {
return gulp.src(['./public/css/main.min.css', './public/css/vendor.min.css'])
.pipe(minifyCss())
.pipe(gulp.dest('./public/css'));
});
gulp.task('watch', () => {
gulp.watch('./assets/js/*.js', ['scripts']);
gulp.watch('./assets/js/vendor/*.js', ['vendor-js']);
gulp.watch('./assets/css/vendor/*.css', ['vendor-css']);
gulp.watch('./assets/sass/**/*.scss', ['sass']);
});
gulp.task('minify', ['minify-css', 'minify-js']);
gulp.task('concat', ['vendor-css', 'vendor-js', 'scripts', 'sass']);
gulp.task('deploy', ['concat', 'minify']);
gulp.task('default', ['concat', 'watch']);