forked from souhe/reactScrollbar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
94 lines (80 loc) · 2.79 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
var gulp = require('gulp');
var webpack = require('webpack-stream');
var concat = require('gulp-concat');
var less = require('gulp-less');
var babel = require('gulp-babel');
var connect = require('gulp-connect');
var merge = require('merge-stream');
var runSequence = require('run-sequence');
var webpackDevConf = require('./webpack.dev.config.js');
var webpackProductionConf = require('./webpack.production.config.js');
var webpackExamplesConf = require('./webpackExamples.config.js');
gulp.task('build', function() {
return gulp.src('src/js/ScrollAreaWithCss.js')
.pipe(webpack(webpackDevConf))
.pipe(concat('scrollArea.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('build-nocss', function() {
return gulp.src('src/js/ScrollAreaWithoutCss.js')
.pipe(webpack(webpackDevConf))
.pipe(concat('no-css.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('build-production', function() {
return gulp.src('src/js/ScrollAreaWithCss.js')
.pipe(webpack(webpackProductionConf))
.pipe(concat('scrollArea.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('build-production-nocss', function() {
return gulp.src('src/js/ScrollAreaWithoutCss.js')
.pipe(webpack(webpackProductionConf))
.pipe(concat('no-css.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('less', function(){
return gulp.src('./src/less/scrollArea.less')
.pipe(less())
.pipe(gulp.dest('./dist/css/'));
});
var folders = ['basic', 'changingChildren'];
gulp.task('build-examples', function(){
var tasks = folders.map(function(folder){
return gulp.src('examples/' + folder + '/js/main.js', {base: './'})
.pipe(webpack( webpackExamplesConf ))
.pipe(concat('main.js'))
.pipe(gulp.dest('examples/' + folder ));
});
return merge(tasks)
.pipe(connect.reload());
});
gulp.task("connect", function(){
connect.server({
root: 'dist',
livereload: true,
port: 8003
});
});
gulp.task('less-examples', function(){
return gulp.src('./examples/**/less/**/*.less')
.pipe(less())
.pipe(gulp.dest('../'))
.pipe(connect.reload());
});
gulp.task('default', function(callback){
runSequence('build', 'build-nocss', 'less', ['build-examples', 'less-examples'], callback);
});
gulp.task('production', function(callback){
runSequence('build-production', 'build-production-nocss', 'less', callback);
});
gulp.task('watch', function() {
connect.server({
root: 'examples/basic',
livereload: true,
port: 8003
});
gulp.watch(['src/**/*.js', 'src/**/*.jsx', 'src/**/*.less'], ['default']);
gulp.watch(['examples/**/js/**/*.js', 'examples/**/*.jsx'], ['build-examples']);
gulp.watch('examples/**/*.less', ['less-examples']);
});