This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
forked from hyojin/material-ui-datatables
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (76 loc) · 2.15 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const gulp = require('gulp');
const browserify = require('browserify');
const watchify = require('watchify');
const babelify = require('babelify');
const source = require('vinyl-source-stream');
const eslint = require('gulp-eslint');
const browserSync = require('browser-sync').create();
const babel = require('gulp-babel');
const del = require('del');
const copy = require('gulp-copy');
const mocha = require('gulp-mocha');
function map_error(err) {
console.log('Error : ' + err.message);
this.emit('end');
};
function bundle_js(bundler) {
return bundler.bundle()
.on('error', map_error)
.pipe(source('bundle.js'))
.pipe(gulp.dest('./example/app'));
};
gulp.task('watchify', () => {
const bundler = watchify(browserify('./example/src/app.js', Object.assign(watchify.args, { debug: true }))
.transform('babelify', { presets: ['es2015', 'react', 'stage-1'] }), { verbose: true });
bundle_js(bundler);
bundler.on('update', () => {
bundle_js(bundler);
});
bundler.on('log', (msg) => {
console.log(msg);
});
});
gulp.task('browserSync', function() {
browserSync.init({
notify: false,
port: 3000,
open: true,
server: {
baseDir: ['example/app']
},
});
gulp.watch('example/app/bundle.js').on('change', browserSync.reload);
});
gulp.task('eslint', function() {
return gulp.src(['src/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('build:clean', function() {
del.sync(['build']);
});
gulp.task('build', () => {
return gulp.src('src/**/*.js')
.pipe(babel({
presets: ['es2015', 'stage-1', 'react'],
plugins: ['transform-runtime']
}))
.pipe(gulp.dest('build/'));
});
gulp.task('build:copy', function() {
return gulp.src(['package.json', 'README.md', 'LICENSE'])
.pipe(copy('build/', {prefix: 1}));
});
gulp.task('test', function() {
return gulp.src(['.mochasetup.js', 'test/**/*.spec.js'])
.pipe(babel({
presets: ['es2015', 'stage-1', 'react'],
plugins: ['transform-runtime']
}))
.pipe(mocha({
reporter: 'spec',
}));
});
gulp.task('clean:build', ['build:clean', 'build', 'build:copy']);
gulp.task('default', ['watchify', 'browserSync']);