-
Notifications
You must be signed in to change notification settings - Fork 17
/
gulpfile.js
72 lines (63 loc) · 2.53 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
/* globals require */
'use strict'; // jshint ignore:line
var gulp = require('gulp'),
// Plugins
wrap = require('gulp-wrap'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
minify = require('gulp-minify'),
minCss = require('gulp-minify-css'),
header = require('gulp-header'),
replace = require('gulp-replace'),
// Helpers
gh = require('./gulphelpers'),
packageJson = require('./package.json'),
moduleOrder;
// Module concatenation order
moduleOrder = [
gh.modulePath('helpers'),
gh.modulePath('visualization'),
gh.modulePath('eventmgr'),
gh.modulePath('uictrl'),
gh.modulePath('core')
];
// Builds the jqkeyboard.js from the separated modules
gulp.task('default', function () {
return gulp.src(moduleOrder)
//.pipe(replace(/\n/g, ' ')) // Adds tabulation to concatenated modules
.pipe(replace(/'use strict';var/g, '')) // Removes the strict mode from modules (There is global one in wrapper)
.pipe(replace(new RegExp('//jshint ignore:line', 'g'), '')) // Removes module-specific JSHint ignored lines
.pipe(concat('jqkeyboard.js', { newLine: '\n\n' })) // Concatenates the modules in jqkeyboard.js
.pipe(wrap({ src: gh.DEV_DIR_PREFIX + '_main.js' })) // Wraps the modules in the IIFE
.pipe(header(gh.uncompressedHeader, { pkg: packageJson })) // Puts a header with information
.pipe(gulp.dest('./development/build')); // Saves at build/
});
// Alias of 'default'
gulp.task('build', ['default']);
// Minifies jqKeyboards (independently from ./build/jqkeyboard.js)
gulp.task('_minify:js', function () {
return gulp.src(moduleOrder)
.pipe(replace(/'use strict';var/g, ''))
.pipe(concat('jqkeyboard.js'))
.pipe(wrap({ src: gh.DEV_DIR_PREFIX + '_main.js' }))
.pipe(minify())
.pipe(gulp.dest('./dist/'));
});
// Calls 'minify:js' and cleans the uncompressed file from ./dist/
gulp.task('_clean:js', ['_minify:js'], function () {
return gulp.src('./dist/jqkeyboard.js')
.pipe(clean());
});
// Minifies the currently used development theme
gulp.task('minify:css', function () {
return gulp.src('./development/css/jqkeyboard.css')
.pipe(minCss())
.pipe(header(gh.compressedHeader, { pkg: packageJson })) // Adds header
.pipe(gulp.dest('./dist/'));
});
// Executes minification of both JS and CSS, and adds header to minified js file
gulp.task('dist', ['_clean:js', 'minify:css'], function () {
return gulp.src('./dist/jqkeyboard-min.js')
.pipe(header(gh.compressedHeader, { pkg: packageJson }))
.pipe(gulp.dest('./dist/'));
});