forked from hsnaydd/moveTo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (56 loc) · 1.6 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
'use strict';
const gulp = require('gulp');
const del = require('del');
const runSequence = require('run-sequence');
const browserSync = require('browser-sync');
const gulpLoadPlugins = require('gulp-load-plugins');
const lazypipe = require('lazypipe');
const $ = gulpLoadPlugins();
const reload = browserSync.reload;
const pkg = require('./package.json');
const today = $.util.date('dd-mm-yyyy HH:MM');
const browserSyncConfigs = {
notify: false,
// Disable open automatically when Browsersync starts.
open: false,
server: ['./'],
port: 3000
};
const banner = [
'/*!',
' * MoveTo - ' + pkg.description,
' * Version ' + pkg.version + ' (' + today + ')',
' * Licensed under ' + pkg.license,
' * Copyright ' + $.util.date('yyyy') + ' ' + pkg.author,
' */\n\n'
].join('\n');
gulp.task('scripts:lint', (cb) => {
return gulp.src('src/scripts/**/*.js')
.pipe($.eslint())
.pipe($.eslint.format())
.pipe(browserSync.active ? $.util.noop() : $.eslint.failOnError());
});
gulp.task('scripts', ['scripts:lint'], () => {
const scriptsMinChannel = lazypipe()
.pipe($.uglify)
.pipe($.rename, {suffix: '.min'})
.pipe($.header, banner)
.pipe(gulp.dest, 'dist/');
return gulp.src('src/**/*.js')
.pipe($.babel())
.pipe($.header(banner))
.pipe(gulp.dest('dist'))
.pipe(scriptsMinChannel());
});
gulp.task('clean:dist', () => del(['dist/*'], {dot: true}));
gulp.task('build', (cb) =>
runSequence(
['clean:dist'],
['scripts'],
cb
)
);
gulp.task('serve', () => {
browserSync(browserSyncConfigs);
gulp.watch(['src/**/*.js'], ['scripts', reload]);
});