This repository has been archived by the owner on May 19, 2021. It is now read-only.
forked from Ilyaololo/react-material-datetimepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
74 lines (69 loc) · 2.34 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
let argv = require('yargs').argv,
babelify = require('babelify'),
browserify = require('browserify'),
buffer = require('vinyl-buffer'),
concat = require('gulp-concat'),
gulp = require('gulp'),
gulpif = require('gulp-if'),
less = require('gulp-less'),
myth = require('gulp-myth'),
sass = require('gulp-sass'),
source = require('vinyl-source-stream'),
sourcemaps = require('gulp-sourcemaps'),
streamify = require('gulp-streamify'),
uglify = require('gulp-uglify'),
watchify = require('watchify');
gulp.task('scripts', () => {
let cb = browserify({
//entries: ['./app.js'],
entries: ['./src/DataTimePicker/DataTimePicker.jsx'],
debug: true,
cache: {},
packageCache: {},
fullPaths: true,
extensions: ['.jsx', '.js'],
plugin: [watchify]
});
let rebundle = () => {
cb.transform(babelify);
cb.bundle()
.on('error', (err) => {
console.error(err);
this.emit('end');
})
.pipe(source('react-material-datetime-picker.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./build/'));
};
cb.on('update', rebundle);
rebundle();
});
gulp.task('convert-sass', function () {
gulp.src('./src/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(myth())
.pipe(concat("react-material-datetime-picker.css"))
.pipe(sourcemaps.write())
.pipe(gulp.dest('build/'));
});
gulp.task('js', function () {
let cb = browserify({
entries: ['./src/DataTimePicker/DataTimePicker.jsx'], // Only need initial file, browserify finds the deps
//entries: ['./app.js'],
debug: !argv.prod, // Gives us sourcemapping
cache: {},
packageCache: {},
fullPaths: true,
extensions: ['.jsx', '.js']
});
process.env.NODE_ENV = argv.prod ? "production" : "development";
cb.transform(babelify.configure());
cb.bundle()
.pipe(source('react-material-datetime-picker.js'))
.pipe(gulpif(argv.prod, streamify(uglify())))
.pipe(gulp.dest('./build/'));
});
gulp.task('default', ['convert-sass', 'js']);