-
Notifications
You must be signed in to change notification settings - Fork 17
/
gulpfile.js
87 lines (64 loc) · 1.88 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
var path = require("path");
var fs = require("fs");
// https://github.com/gulpjs/gulp/tree/master/docs
// https://github.com/gulpjs/gulp/blob/master/docs/API.md
var gulp = require('gulp');
var webpack = require("webpack");
// https://github.com/terinjokes/gulp-uglify
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var gutil = require("gulp-util");
// http://browsersync.io/
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var webpackConfig = require("./webpack.config");
var webpackDemoConfig = require("./webpack.demo");
gulp.task("default", ["server"]);
gulp.task("watch", ["server"]);
gulp.task("start", ["server"]);
gulp.task("server", ["demo"], function (callback) {
browserSync({
server: {
baseDir: './',
index: './demo/index.html'
},
open: 'external'
});
gulp.watch(['src/**/*.js', 'demo/**/*.js'], ['reload_demo']);
callback();
});
gulp.task("demo", function (callback) {
webpack(webpackDemoConfig, function (err) {
if (err) {
throw new gutil.PluginError("webpack", err);
}
callback();
});
});
gulp.task('reload_demo', ['demo'], function () {
reload();
});
gulp.task("build", function (callback) {
webpack(webpackConfig, function (err, stats) {
if (err) {
throw new gutil.PluginError("webpack", err);
}
gutil.log("[webpack]", stats.toString({
colors: true
}));
callback();
});
});
gulp.task("min", function (callback) {
gulp.src('dist/uploadcore.js')
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('dist'));
callback();
});
gulp.task('flash', function (callback) {
gulp.src('src/flash/bin/FlashPicker.swf')
.pipe(rename('flashpicker.swf'))
.pipe(gulp.dest('dist'));
callback();
});