forked from ajbarry3/createjs-module
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.es6.js
57 lines (50 loc) · 1.6 KB
/
gulpfile.es6.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
import fs from 'fs';
import gulp from 'gulp';
import concat from 'gulp-concat';
import insert from 'gulp-insert';
import gutil from 'gulp-util';
const VERSIONS = {
EASEL: '1.0.0',
PRELOAD: '1.0.0',
SOUNDL: '1.0.0',
TWEEN: '1.0.0',
CREATE: '1.0.0'
};
const SRC = {
EASEL: `./node_modules/easeljs/lib/easeljs.js`,
PRELOAD: `./node_modules/preloadjs/lib/preloadjs.js`,
SOUND: `./node_modules/soundjs/lib/soundjs.js`,
TWEEN: `./node_modules/tweenjs/lib/tweenjs.js`
};
const DEST = {
CREATE: './'
};
function string_src(filename, string) {
var src = require('stream').Readable({ objectMode: true });
src._read = function () {
this.push(new gutil.File({ cwd: '', base: '', path: filename, contents: new Buffer(string) }));
this.push(null)
};
return src
}
function compile() {
return gulp.src([
SRC.EASEL,
SRC.PRELOAD,
SRC.SOUND,
SRC.TWEEN
])
.pipe(concat('createjs.js'))
.pipe(insert.prepend('var createjs = (this.createjs = (this.createjs || {}));\n'))
.pipe(insert.append('\nif(typeof module !== "undefined" && typeof module.exports !== "undefined") module.exports = this.createjs;'))
.pipe(gulp.dest(DEST.CREATE));
}
function doPackage() {
let pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
pkg.version = VERSIONS.CREATE;
return string_src('package.json', JSON.stringify(pkg, null, 4))
.pipe(gulp.dest(DEST.CREATE));
}
gulp.task('compile', gulp.series(compile));
gulp.task('package', gulp.series(doPackage));
gulp.task('default', gulp.series(compile, doPackage));