-
-
Notifications
You must be signed in to change notification settings - Fork 93
/
gulpfile.js
36 lines (35 loc) · 1.2 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
const gulp = require('gulp');
const browserify = require('browserify');
const uglify = require('gulp-uglify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const header = require('gulp-header');
const insert = require('gulp-insert');
const pkg = require('./package.json');
gulp.task('build', () => {
return browserify(pkg.main).bundle()
.pipe(source(pkg.name + '.min.js'))
.pipe(buffer())
.pipe(insert.wrap(
';!function() {' +
' var name = \'RandExp\';' +
' var obj = (function() { return ',
'})()(1);' +
' if (typeof define === \'function\' && ' +
' typeof define.amd === \'object\') {' +
' define(name, function() { return obj; });' +
' } else if (typeof window !== \'undefined\') {' +
' window[name] = obj;' +
' }' +
'}();'))
.pipe(uglify())
.pipe(header(
'//\n' +
'// ${pkg.name} v${pkg.version}\n' +
'// ${pkg.description}\n' +
'//\n' +
'// Copyright (C) ${year} by ${pkg.author}\n' +
'// ${pkg.license} License\n' +
'//\n', { pkg: pkg, year: new Date().getFullYear() }))
.pipe(gulp.dest('build'));
});