-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
90 lines (81 loc) · 2.15 KB
/
gulpfile.babel.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import gulp from 'gulp';
import plumber from 'gulp-plumber';
import postcss from 'gulp-postcss';
import stylelint from "stylelint";
import reporter from "postcss-reporter";
import sourcemaps from 'gulp-sourcemaps';
import babel from 'gulp-babel';
import uglify from 'gulp-uglify';
import eslint from "gulp-eslint";
import sync from 'browser-sync';
import autoprefixer from 'autoprefixer';
import conventionalChangelog from 'gulp-conventional-changelog';
gulp.task('server', () => {
return sync({
server: {
baseDir: './'
},
open: 'external',
port: 9000
});
});
gulp.task('reload', () => {
return sync.reload();
});
gulp.task('css', () => {
return gulp.src('./src/css/*.css')
.pipe(sourcemaps.init())
.pipe(plumber({
errorHandler: err => {
console.log(err.messageFormatted);
this.emit('end');
}
}))
.pipe(postcss([
autoprefixer(),
require('postcss-nested'),
require('postcss-custom-properties'),
require('postcss-calc'),
stylelint(),
reporter({ clearMessages: true }),
require('cssnano'),
]))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist/css'));
});
gulp.task('babel', ["lint"], () => {
return gulp.src('./src/js/*.es6')
.pipe(plumber({
errorHandler: err => {
console.log(err.messageFormatted);
this.emit('end');
}
}))
.pipe(babel({
presets: ['es2015']
}))
.pipe(uglify({preserveComments: 'some'}))
.pipe(gulp.dest('./dist/js/'))
});
gulp.task("lint", () => {
return gulp.src("./src/js/*.es6")
.pipe(eslint({useEslintrc : true}))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('changelog', () => {
return gulp.src('CHANGELOG.md')
.pipe(conventionalChangelog({
preset: 'angular'
}))
.pipe(gulp.dest('./'));
});
gulp.task('w', ['build', 'server'], () => {
gulp.watch('./src/css/*.css', ['css']);
gulp.watch('./src/js/*.es6', ['babel']);
gulp.watch('./*.html', ['reload']);
gulp.watch('./dist/**/**.css', ['reload']);
return gulp.watch('./dist/**/*.js', ['reload']);
});
gulp.task('build', ['css']);
gulp.task('default', ['build']);