1 | var gulp = require('gulp');
|
2 | var rename = require('gulp-rename');
|
3 | var uglify = require('gulp-uglify');
|
4 | var webpack = require('webpack-stream');
|
5 | var browserSync = require('browser-sync').create();
|
6 |
|
7 | var webpackDevConf = require('./webpack.dev.config.js'),
|
8 | webpackProdConf = require('./webpack.prod.config.js');
|
9 |
|
10 | gulp.task('build', function() {
|
11 | return gulp.src('test/main.js')
|
12 | .pipe(webpack(webpackDevConf))
|
13 | .pipe(rename('main.js'))
|
14 | .pipe(gulp.dest('.tmp'))
|
15 | .pipe(browserSync.stream());
|
16 | });
|
17 |
|
18 | gulp.task('dist', function() {
|
19 | return gulp.src('src/react-smooth-scrollbar.js')
|
20 | .pipe(webpack(webpackProdConf))
|
21 | .pipe(uglify())
|
22 | .pipe(rename('react-smooth-scrollbar.js'))
|
23 | .pipe(gulp.dest('dist'));
|
24 | });
|
25 |
|
26 | gulp.task('watch', function() {
|
27 | gulp.watch(['test/main.js', 'src/react-smooth-scrollbar.js'], ['build']);
|
28 | gulp.watch('test/*.{css,html}').on('change', browserSync.reload);
|
29 | })
|
30 |
|
31 | gulp.task('serve', ['build', 'watch'], function() {
|
32 | browserSync.init({
|
33 | server: {
|
34 | baseDir: 'test/',
|
35 | routes: {
|
36 | '/compiled': '.tmp/',
|
37 | '/node_modules': 'node_modules/'
|
38 | }
|
39 | }
|
40 | });
|
41 | });
|
42 |
|
43 | gulp.task('default', ['serve']);
|