-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·72 lines (52 loc) · 1.41 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
// Defining settings
var settings = {
nodePath: './node_modules/',
jsPath: './js-src/'
};
// Defining requirements
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var replace = require('gulp-replace');
var sourcemaps = require('gulp-sourcemaps');
var del = require('del');
// Run:
// gulp clean-js
// Delete existing generated js files
gulp.task( 'clean-js', function( done ) {
del.sync( [ './dist/*.js', './dist/maps/*.map' ] );
done();
} );
// Run:
// gulp build-js.
// Uglifies and concat all JS files into one
gulp.task( 'build-js', gulp.series( 'clean-js', function( done ) {
gulp.src([
settings.jsPath + '*.js',
])
.pipe(sourcemaps.init())
.pipe(gulp.dest('./dist/')) // save .js
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest('./dist/')); // save .min.js
done();
} ) );
// Run:
// gulp watch
// Starts watcher. Watcher runs appropriate tasks on file changes
gulp.task( 'watch', function ( done ) {
gulp.watch('./js-src/**/*.js', gulp.series( 'build-js' ) );
gulp.watch('./package.json', gulp.series( 'build' ) );
done();
} );
// Run:
// gulp build
// Build css and js assets
gulp.task( 'build', gulp.series( 'build-js' ) );
// Run:
// gulp
// Defines gulp default task
gulp.task( 'default', gulp.series( 'watch' ) );