-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
47 lines (41 loc) · 1.06 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
const gulp = require('gulp');
const babel = require('gulp-babel');
const del = require('del');
const webpackStream = require('webpack-stream');
const webpack2 = require('webpack');
const path = require('path');
const fs = require('fs');
const nodeModules = {};
fs.readdirSync('node_modules')
.filter(x => {
return ['.bin'].indexOf(x) === -1;
})
.forEach(mod => {
nodeModules[mod] = `commonjs ${mod}`;
});
gulp.task('clean', () => {
return del(['dist']);
});
gulp.task('cleanbuild', () => {
return del(['build']);
});
gulp.task('babel', ['clean'], () => {
return gulp.src(['./app/**/*.js'])
.pipe(babel({
presets: ['es2015'],
}))
.pipe(gulp.dest('dist'));
});
gulp.task('webpack', ['babel', 'cleanbuild'], () => {
return gulp.src(['./dist/index-browser.js'])
.pipe(webpackStream({
output: {
filename: 'bundle-browser.js',
path: path.resolve(__dirname, 'build'),
},
}, webpack2))
.pipe(gulp.dest('build'));
});
gulp.task('watch', ['babel'], () => {
gulp.watch(['./app/**/*.js'], ['babel']);
});