-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·64 lines (57 loc) · 1.76 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
var gulp = require('gulp');
var del = require('del');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var webpack = require('gulp-webpack');
var eslint = require('gulp-eslint');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var sass = require('gulp-sass');
var webpackConfig = require('./webpack.config.js');
gulp.task('clean', function() {
//return del.sync(['dist']);
});
gulp.task('build', function() {
return gulp.src('./js/*.js')
.pipe(plumber({
errorHandler: notify.onError("Error: <%= error.message %>")
}))
.pipe(eslint({useEslintrc: true}))
.pipe(eslint.format())
.pipe(eslint.failOnError())
.pipe(webpack(webpackConfig))
.pipe(gulp.dest('./dist'));
});
gulp.task('sass', function() {
return gulp.src('./sass/*.scss')
.pipe(plumber({
errorHandler: notify.onError("Error: <%= error.message %>")
}))
.pipe(sass())
.pipe(gulp.dest('./dist/css'));
});
gulp.task('js-minify', function() {
return gulp.src('./dist/js/*.js')
.pipe(plumber({
errorHandler: notify.onError("Error: <%= error.message %>")
}))
.pipe(uglify())
.pipe(concat('application.min.js'))
.pipe(gulp.dest('./dist/min'));
});
gulp.task('css-minify', function() {
return gulp.src('./dist/js/*.css')
.pipe(plumber({
errorHandler: notify.onError("Error: <%= error.message %>")
}))
.pipe(uglify())
.pipe(concat('bundle.min.css'))
.pipe(gulp.dest('./dist/min'));
});
gulp.task('watch', function() {
gulp.watch(['./js/*.js'], ['build']);
gulp.watch(['./sass/*.scss'], ['sass']);
});
gulp.task('default', ['clean', 'build', 'sass', 'watch']);
gulp.task('minify', ['js-minify', 'css-minify']);
gulp.task('production', ['clean', 'build', 'sass', 'minify']);