UNPKG

1.06 kBJavaScriptView Raw
1var gulp = require('gulp')
2var uglify = require('gulp-uglify')
3var rename = require('gulp-rename')
4var streamify = require('gulp-streamify')
5var size = require('gulp-size')
6var browserify = require('browserify')
7var source = require('vinyl-source-stream')
8var envify = require('envify')
9var babel = require('gulp-babel')
10var babelify = require("babelify")
11
12gulp.task('build-4-node', function () {
13 return gulp.src('src/**/*.js')
14 .pipe(babel())
15 .pipe(gulp.dest('./lib/'))
16})
17
18gulp.task('build-4-browser', function () {
19 return browserify('./src/iniettore.js', {
20 debug: false,
21 insertGlobals: false,
22 detectGlobals: true,
23 standalone: 'iniettore',
24 noBuiltins: true
25 })
26 .transform(babelify)
27 .transform({
28 NODE_ENV: 'production'
29 }, envify)
30 .bundle()
31 .pipe(source('iniettore.js'))
32 .pipe(gulp.dest('./dist'))
33 .pipe(rename('iniettore.min.js'))
34 .pipe(streamify(uglify()))
35 .pipe(streamify(size()))
36 .pipe(streamify(size({ gzip: true })))
37 .pipe(gulp.dest('./dist'))
38})
39
40gulp.task('build', ['build-4-node', 'build-4-browser'])