1 | var gulp = require('gulp')
|
2 | var uglify = require('gulp-uglify')
|
3 | var rename = require('gulp-rename')
|
4 | var streamify = require('gulp-streamify')
|
5 | var size = require('gulp-size')
|
6 | var browserify = require('browserify')
|
7 | var source = require('vinyl-source-stream')
|
8 | var envify = require('envify')
|
9 | var babel = require('gulp-babel')
|
10 | var babelify = require("babelify")
|
11 |
|
12 | gulp.task('build-4-node', function () {
|
13 | return gulp.src('src/**/*.js')
|
14 | .pipe(babel())
|
15 | .pipe(gulp.dest('./lib/'))
|
16 | })
|
17 |
|
18 | gulp.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 |
|
40 | gulp.task('build', ['build-4-node', 'build-4-browser'])
|