-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
67 lines (57 loc) · 1.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
var gulp = require('gulp');
var babel = require('gulp-babel');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
const browserify = require('browserify');
const babelify = require('babelify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
var paths = {
browser: {
src: 'src/browser_translit.js',
name: 'translit.min.js',
dest: 'dist/'
},
npm: {
src: 'src/translit.js',
name: 'translit_dist.min.js',
dest: 'dist/'
}
};
/*
* Define our tasks using plain functions
*/
function browserBuild() {
return browserify({ entries: paths.browser.src, debug: false })
.transform(babelify)
.bundle()
.pipe(source(paths.browser.name))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest(paths.browser.dest));
}
function npmBuild() {
return gulp.src(paths.npm.src, { sourcemaps: false })
.pipe(babel())
.pipe(uglify())
.pipe(concat(paths.npm.name))
.pipe(gulp.dest(paths.npm.dest));
}
function watch() {
gulp.watch(paths.npm.src, npmBuild);
gulp.watch(paths.browser.src, browserBuild);
}
/*
* Specify if tasks run in series or parallel using `gulp.series` and `gulp.parallel`
*/
var build = gulp.parallel(npmBuild, browserBuild);
/*
* You can use CommonJS `exports` module notation to declare tasks
*/
exports.scripts = npmBuild;
exports.watch = watch;
exports.build = build;
/*
* Define default task that can be called by just running `gulp` from cli
*/
exports.default = build;