-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgulpfile.js
executable file
·126 lines (97 loc) · 3.32 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
var gulp = require( 'gulp' );
var fs = require( 'fs' );
var browserify = require( 'browserify' );
var babelify = require( 'babelify' );
var uglify = require( 'gulp-uglify' );
var header = require( 'gulp-header' );
var _package = require( './package.json' );
var now = new Date();
var year = now.getUTCFullYear();
var licenceLong = `/*!
* Flounder JavaScript Stylable Selectbox v${_package.version}
* ${_package.homepage}
*
* Copyright 2015-${year} Sociomantic Labs and other contributors
* Released under the MIT license
* https://github.com/sociomantic-tsunami/flounder/license
*
* Date: ${now.toDateString()}
*
* "This, so far, is the best Flounder ever"
*/`;
var licenceShort = `/*! Flounder v${_package.version} | (c) 2015-${year} Sociomantic Labs | https://github.com/sociomantic-tsunami/flounder/license */`;
function build( folder, filename, ext )
{
browserifyFiles( folder, filename, ext );
min( folder, filename, ext );
}
function browserifyFiles( folder, filename, ext )
{
ext = ext || '.js';
browserify( './src/' + folder + '/' + filename + ext )
.transform( babelify )
.bundle()
.pipe( fs.createWriteStream( __dirname + '/dist/' + filename + ext ) )
.on( 'finish', function()
{
gulp.src( './dist/' + filename + ext )
.pipe( header( licenceLong ) )
.pipe( gulp.dest( './dist/' ) )
} );
};
function min( folder, filename, ext )
{
ext = ext || '.js';
browserify( './src/' + folder + '/' + filename + ext )
.transform( babelify )
.bundle()
.pipe( fs.createWriteStream( __dirname + '/dist/' + filename + '.min' + ext ) )
.on( 'finish', function()
{
gulp.src( './dist/' + filename + '.min' + ext )
.pipe( uglify() )
.pipe( header( licenceShort ) )
.pipe( gulp.dest( './dist/' ) )
} );
}
gulp.task( 'demo', function()
{
browserify( './demo/demo.js' )
.transform( babelify )
.bundle()
.pipe( fs.createWriteStream( __dirname + '/demo/demoDist.js' ) );
} );
gulp.task( 'vanilla', function()
{
build( 'core', 'flounder' );
} );
gulp.task( 'amd', function()
{
build( 'wrappers', 'flounder.amd' );
} );
gulp.task( 'jquery', function()
{
build( 'wrappers', 'flounder.jquery' );
} );
gulp.task( 'microbe', function()
{
build( 'wrappers', 'flounder.microbe' );
} );
gulp.task( 'default', [], function()
{
gulp.start( [ 'vanilla', 'amd', 'jquery', 'microbe', 'demo' ] );
} );
gulp.task( 'compile', [], function()
{
browserifyFiles( 'core', 'flounder' );
browserifyFiles( 'wrappers', 'flounder.amd' );
browserifyFiles( 'wrappers', 'flounder.jquery' );
browserifyFiles( 'wrappers', 'flounder.microbe' );
} );
gulp.task( 'min', [], function()
{
min( 'core', 'flounder' );
min( 'wrappers', 'flounder.amd' );
min( 'wrappers', 'flounder.jquery' );
min( 'wrappers', 'flounder.microbe' );
} );