|
1 | 1 | var gulp = require('gulp'); |
2 | 2 | var babel = require('gulp-babel'); |
| 3 | +var concat = require('gulp-concat'); |
3 | 4 | var del = require('del'); |
4 | 5 |
|
| 6 | +gulp.task('clean-demo', function(){ |
| 7 | + return del(['./demo']); |
| 8 | +}); |
| 9 | + |
5 | 10 | gulp.task('clean-lib', function(){ |
6 | | - return del(['lib']); |
| 11 | + return del(['./lib']); |
| 12 | +}); |
| 13 | + |
| 14 | +gulp.task('build-lib',['clean-lib'], function(){ |
| 15 | + gulp.src(['./src/hmac.js']) |
| 16 | + .pipe(concat('hmac.js')) |
| 17 | + .pipe(gulp.dest('./lib/es6')) |
| 18 | + .pipe(babel({ |
| 19 | + presets: ['es2015'] |
| 20 | + })) |
| 21 | + .pipe(gulp.dest('./lib/es5')); |
7 | 22 | }); |
8 | 23 |
|
9 | | -gulp.task('es5',['clean-lib'], function(){ |
10 | | - return gulp.src(['src/*.js','example/*.js']) |
| 24 | +gulp.task('build-demo',['clean-demo', 'build-lib'], function(){ |
| 25 | + gulp.src('./src/demo/*.html', {base: './src/demo'}) |
| 26 | + .pipe(gulp.dest('./demo')); |
| 27 | + gulp.src('./src/demo/*.php', {base: './src/demo'}) |
| 28 | + .pipe(gulp.dest('./demo')); |
| 29 | + gulp.src(['./src/hmac.js', './src/demo/get.js']) |
| 30 | + .pipe(concat('get.app.js')) |
| 31 | + .pipe(babel({ |
| 32 | + presets: ['es2015'] |
| 33 | + })) |
| 34 | + .pipe(gulp.dest('./demo')); |
| 35 | + gulp.src(['./src/hmac.js', './src/demo/post.js']) |
| 36 | + .pipe(concat('post.app.js')) |
11 | 37 | .pipe(babel({ |
12 | 38 | presets: ['es2015'] |
13 | 39 | })) |
14 | | - .pipe(gulp.dest('lib')); |
| 40 | + .pipe(gulp.dest('./demo')); |
15 | 41 | }); |
16 | 42 |
|
17 | | -gulp.task('default', ['es5'], function() { |
| 43 | +gulp.task('default', ['build-demo'], function() { |
18 | 44 | gulp.watch('src/*.js', function() { |
19 | | - gulp.run('es5'); |
| 45 | + gulp.run('build-demo'); |
20 | 46 | }); |
21 | | - gulp.watch('example/*.js', function() { |
22 | | - gulp.run('es5'); |
| 47 | + gulp.watch('src/demo/*', function() { |
| 48 | + gulp.run('build-demo'); |
23 | 49 | }); |
24 | 50 | }); |
0 commit comments