1 | "use strict";
|
2 | var gulp = require('gulp');
|
3 | var babel = require('gulp-babel');
|
4 | var webpack = require('gulp-webpack');
|
5 | var plumber = require('gulp-plumber');
|
6 | var fse = require('fs-extra');
|
7 | var webpackCfg = require('./webpack.config');
|
8 | var webpackPubCfg = require('./webpack.pub');
|
9 |
|
10 |
|
11 | gulp.task('src', function() {
|
12 | return gulp.src('src/**/*.*')
|
13 | .pipe(plumber())
|
14 | .pipe(babel({
|
15 | only: '*.js',
|
16 | presets: ['es2015', "stage-0"],
|
17 | plugins: ['transform-es2015-modules-commonjs']
|
18 | }))
|
19 | .pipe(gulp.dest('build'));
|
20 | });
|
21 |
|
22 |
|
23 |
|
24 | gulp.task('webpack:watch', function() {
|
25 | return gulp.src('web/src/app/app.jsx')
|
26 | .pipe(webpack(webpackCfg))
|
27 | .pipe(gulp.dest('web/build/app'));
|
28 | });
|
29 | gulp.task('webpack:publish', function() {
|
30 | return gulp.src('web/src/app/app.jsx')
|
31 | .pipe(webpack(webpackPubCfg))
|
32 | .pipe(gulp.dest('web/build/app'));
|
33 | });
|
34 |
|
35 | gulp.task('web-dest', function() {
|
36 | return gulp.src('web/src/**/+(*.html|*.ejs|*.css|*.eot|*.svg|*.ttf|*.woff)')
|
37 | .pipe(gulp.dest('web/build'));
|
38 | });
|
39 |
|
40 |
|
41 | gulp.task('watch', function() {
|
42 | gulp.watch('web/src/**/*.*', ['web-dest']);
|
43 | gulp.watch('./src/**/*.*', ['src']);
|
44 | });
|
45 |
|
46 | gulp.task('clean', function(cb) {
|
47 | fse.emptyDirSync('./build');
|
48 | fse.emptyDirSync('./web/build');
|
49 | cb();
|
50 | });
|
51 |
|
52 |
|
53 | gulp.task('publish', ["clean", "src", 'web-dest', 'webpack:publish']);
|
54 |
|
55 | gulp.task('build', ["src", 'web-dest', 'webpack:watch', "watch"]);
|
56 |
|
57 | process.on('uncaughtException', function(err) {
|
58 | console.log(err);
|
59 | }); |
\ | No newline at end of file |