forked from blueberryapps/translation-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (61 loc) · 2.01 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
const gulp = require('gulp');
const babelify = require('babelify');
const watchify = require('watchify');
const fs = require('fs');
const browserify = require('browserify');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const path = require('path');
const babelrc = JSON.parse(fs.readFileSync('./.babelrc'));
const configureSvgIcon = require('react-svg-icon-generator').default;
function swallowError(error) {
console.log(error.stack); // eslint-disable-line
this.emit('end');
}
function build() {
return browserify('./app/react/main.js')
.transform(babelify.configure(babelrc))
.bundle()
.on('error', swallowError)
.pipe(fs.createWriteStream('./public/react_assets/react.js'));
}
function watch() {
const b = browserify({
entries: ['./app/react/main.js'],
cache: {}, // required for watchify
packageCache: {}, // required for watchify
debug: process.env.DEBUG,
plugin: [watchify],
});
b.transform(babelify.configure(babelrc));
function rebuild() {
const startedAt = new Date();
console.log('Build started at ' + startedAt); //eslint-disable-line
b
.bundle()
.on('error', swallowError)
.pipe(fs.createWriteStream('./public/react_assets/react.js'))
.on('finish', () =>
console.log('Finished in ' + (new Date().getTime() - startedAt.getTime()) + 'ms')); //eslint-disable-line
}
b.on('error', swallowError);
b.on('update', rebuild);
b.bundle().pipe(fs.createWriteStream('./public/react_assets/react.js'));
return rebuild();
}
gulp.task('build', () => {
console.log('Building ES6'); // eslint-disable-line
build();
});
configureSvgIcon({
comment: 'Generated by gulp svg-icon, if you add new icon run gulp svg-icon',
componentName: 'Icon',
destination: path.join('app', 'react', 'components', 'Icon.react.js'),
keepFillColor: false,
native: false,
radium: true,
reactPureRender: true,
svgDir: path.join('app', 'assets', 'icons'),
});
gulp.task('default', ['watch']);
gulp.task('watch', () => watch());