forked from toolforge/video2commons
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGulpfile.js
35 lines (30 loc) · 1.28 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
/* eslint-env node */
var gulp = require( 'gulp' );
var uglify = require( 'gulp-uglify' );
var rename = require( 'gulp-rename' );
var htmlmin = require( 'gulp-htmlmin' );
gulp.task( 'scripts', function () {
return gulp
.src( [ './video2commons/frontend/static/*.js', '!./video2commons/frontend/static/*.min.js' ] )
.pipe( rename( { suffix: '.min' } ) )
.pipe( uglify() )
.pipe( gulp.dest( './video2commons/frontend/static/' ) );
} );
gulp.task( 'html', function () {
return gulp
.src( [ './video2commons/frontend/**/*.html', '!./video2commons/frontend/**/*.min.html' ] )
.pipe( rename( { suffix: '.min' } ) )
.pipe( htmlmin( { collapseWhitespace: true, minifyCSS: true } ) )
.pipe( gulp.dest( './video2commons/frontend/' ) );
} );
gulp.task( 'watch', function () {
var changeevent = function ( event ) {
// eslint-disable-next-line no-console
console.log( 'File ' + event.path + ' was ' + event.type + ', running tasks...' );
};
gulp.watch( [ './video2commons/frontend/static/*.js', '!./video2commons/frontend/static/*.min.js' ], [ 'scripts' ] )
.on( 'change', changeevent );
gulp.watch( [ './video2commons/frontend/**/*.html', '!./video2commons/frontend/**/*.min.html' ], [ 'html' ] )
.on( 'change', changeevent );
} );
gulp.task( 'default', [ 'scripts', 'html', 'watch' ] );