-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
46 lines (40 loc) · 1.52 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
const gulp = require('gulp');
const exec = require('child_process').exec;
const htmlreplace = require('gulp-html-replace');
const _ = require("underscore");
const fs = require('fs-extra');
const rename = require("gulp-rename");
const path = require("path");
gulp.task('clean', function () {
// Deletes contents as well, like rm -rf
fs.removeSync('./build');
});
gulp.task('default', ['build-typescript'], function () {
const time = Date.now();
const files = [
"./node_modules/react/umd/react.development.js",
"./node_modules/react-dom/umd/react-dom.development.js",
"./node_modules/react-dom/umd/react-dom-server.browser.development.js",
"./node_modules/react-dom/umd/react-dom-test-utils.development.js",
"./node_modules/react-dom-factories/index.js",
"./node_modules/redux/dist/redux.js",
"./node_modules/react-redux/dist/react-redux.js",
"dependencies/require.js",
'build/typescript.js'
];
gulp.src(files)
.pipe(rename(function(path) {
path.basename += "-" + time;
}))
.pipe(gulp.dest('./build'));
gulp.src('./index.html')
.pipe(htmlreplace({ resources: _.map(files, file => path.basename(file, '.js') + "-" + time + path.extname(file)) }))
.pipe(gulp.dest('./build'));
});
gulp.task('build-typescript', ['clean'], function (cb) {
exec('"node_modules/.bin/tsc" --project tsconfig.json', function (err, stdout, stderr) {
if (stdout) console.log(stdout);
if (stderr) console.log(stderr);
cb(err);
});
});