forked from jquense/react-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
110 lines (83 loc) · 2.45 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
'use strict';
var gulp = require('gulp')
, del = require('del')
, merge = require('merge-stream')
, webpack = require('webpack')
, WebpackServer = require("webpack-dev-server")
, less = require('gulp-less')
, assign = require('lodash/object/assign')
, rename = require('gulp-rename')
, babelTransform = require('gulp-babel-helpers')
, plumber = require('gulp-plumber')
, configs = require('./webpack.configs');
gulp.task('lib-clean', function(cb){
del('./lib', cb);
})
gulp.task('lib-assets', [ 'lib-clean' ], function(){
return merge(
gulp.src('./src/less/*.less')
.pipe(gulp.dest('./lib/less')),
gulp.src('./src/img/*')
.pipe(gulp.dest('./lib/img')),
gulp.src('./src/fonts/*')
.pipe(gulp.dest('./lib/fonts'))
);
})
gulp.task('lib-compile', [ 'lib-clean' ], function(){
return gulp.src(['./src/**/*.js', './src/**/*.jsx'])
.pipe(plumber())
.pipe(babelTransform(
configs.babel
, './util/babelHelpers.js'
, './lib/util/babelHelpers.js'))
.pipe(rename({ extname: '.js' }))
.pipe(gulp.dest('./lib'));
})
gulp.task('lib', [ 'lib-clean', 'lib-assets', 'lib-compile'])
gulp.task('dist-assets', function(){
return merge(
gulp.src('./src/less/*.css')
.pipe(gulp.dest('./dist/css')),
gulp.src('./src/img/*')
.pipe(gulp.dest('./dist/img')),
gulp.src('./src/fonts/*')
.pipe(gulp.dest('./dist/fonts'))
);
})
gulp.task('dist-build', [ 'lib' ], function(cb) {
del('./dist/*.js', function(){
webpack(configs.browser, cb);
});
})
gulp.task('docs', ['lib', 'assets'], function(cb) {
webpack(assign({}, configs.docs, { devtool: '' }), cb);
})
gulp.task('doc-watch', function() {
del('./docs/docs.js', function(cb){
new WebpackServer(webpack(configs.docs), {
publicPath: "/docs",
hot: true,
hotComponent: true,
stats: { colors: true }
}
)
.listen(8081, "localhost", cb);
});
})
gulp.task('dev', function(cb) {
new WebpackServer(webpack(configs.dev), {
publicPath: "/dev",
hot: true,
hotComponent: true,
stats: { colors: true }
})
.listen(8080, 'localhost', function (err, result) {
if (err)
return console.log(err);
console.log('Listening at localhost:8080');
cb()
});
})
gulp.task('dev-docs', ['lib', 'doc-watch'])
gulp.task('dist', ['dist-assets', 'dist-build'])
gulp.task('release', [ 'lib', 'dist', 'docs']);