-
Notifications
You must be signed in to change notification settings - Fork 44
/
Gulpfile.js
59 lines (52 loc) · 1.1 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
'use strict';
/**
* Module Dependencies.
*/
var mkdirp = require('mkdirp');
var gulp = require('gulp');
var header = require('gulp-header');
var replace = require('gulp-replace');
var rename = require('gulp-rename');
var ugifyjs = require('gulp-uglify');
/**
* Package
*/
var pkg = require('./package.json');
/**
* Prefix
*/
var prefix = ['/**',
' * <%= pkg.name %> - v<%= pkg.version %>',
' *',
' * Copyright (c) ' + new Date().getFullYear() + ', <%= pkg.author %>',
' * Released under the MIT license.',
' */',
''].join('\n');
/**
* Create directory
*/
mkdirp('./dist');
/**
* Build task
*/
gulp.task('build', function() {
gulp.src('./index.js')
.pipe(header(prefix, { 'pkg' : pkg }))
.pipe(replace('module.exports = ', ''))
.pipe(rename(pkg.name + '.js'))
.pipe(gulp.dest('./dist/'))
});
/**
* Min task
*/
gulp.task('min', function() {
gulp.src('./dist/' + pkg.name + '.js')
.pipe(ugifyjs())
.pipe(rename(pkg.name + '.min.js'))
.pipe(gulp.dest('./dist/'));
});
/**
* Register tasks
*/
gulp.task('default', ['build']);
gulp.task('dist', ['build', 'min']);