-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
67 lines (52 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
65
66
67
"use strict";
const gulp = require( "gulp" );
const concat = require( "gulp-concat" );
const eslint = require( "gulp-eslint" );
const header = require( "gulp-header" );
const rename = require( "gulp-rename" );
const uglify = require( "gulp-uglify" );
const pkg = require( "./package.json" );
const uglifyOpts = { output: { comments: /(^!|@preserve)/i } };
const date = new Date();
const banner = `/**
* Donutty ~ ${ pkg.description }
* ${ date.getDate() }/${ date.getMonth() + 1 }/${ date.getFullYear() }
* @author ${ pkg.author.name } <${ pkg.author.email }>
* @version ${ pkg.version }
* @license ${ pkg.license }
* @link ${ pkg.author.url }
* @preserve
*/
`;
function lint() {
return gulp.src([ "./src/*.js", "*.js" ])
.pipe( eslint() )
.pipe( eslint.format() )
.pipe( eslint.failAfterError() );
}
function buildvanilla() {
return gulp.src([ "./src/donutty.js", "./src/vanilla.js" ])
.pipe( concat( "donutty.js" ) )
.pipe( header( banner ) )
.pipe( gulp.dest( "./dist" ) )
.pipe( uglify( uglifyOpts ) )
.pipe( rename( "donutty.min.js" ) )
.pipe( gulp.dest( "./dist" ) );
}
function buildjquery() {
return gulp.src([ "./src/donutty.js", "./src/jquery.js" ])
.pipe( concat( "donutty-jquery.js" ) )
.pipe( header( banner ) )
.pipe( gulp.dest( "./dist" ) )
.pipe( uglify( uglifyOpts ) )
.pipe( rename( "donutty-jquery.min.js" ) )
.pipe( gulp.dest( "./dist" ) );
}
const jquery = gulp.series( lint, buildjquery );
const vanilla = gulp.series( lint, buildvanilla );
const build = gulp.series( lint, buildjquery, buildvanilla );
exports.lint = lint;
exports.jquery = jquery;
exports.vanilla = vanilla;
exports.build = build;
exports.default = build;