/
gulpfile.js
executable file
·37 lines (32 loc) · 1.24 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
const gulp = require('gulp')
const browserify = require('browserify')
const babelify = require('babelify')
const gutil = require('gulp-util')
const source = require('vinyl-source-stream')
/** NOTE: Therre is not uglify stuff here, because it is only some prototypel stuff **/
/**
* Explanation of what does what:
* Babel: Transpile ES6 to ES5 (doesn't handle ES6 modules)
* Browserify: Crawls code for dependencies and concats into one file
* Babelify: Babel plugin for browserify to include ES6 modules
*/
gulp.task('es6-from-src-to-normal-js-in-public', function() {
browserify({debug: true})
.transform(babelify)
.require('./src/js/every-page.js', { entry: true })
.bundle()
.on('error', gutil.log)
.pipe(source('every-page.js'))
.pipe(gulp.dest('./public/js'))
browserify({debug: true})
.transform(babelify)
.require('./src/js/products-page.js', { entry: true })
.bundle()
.on('error', gutil.log)
.pipe(source('products-page.js'))
.pipe(gulp.dest('./public/js'))
})
gulp.task('watch',function() {
gulp.watch(['./src/js/**/*.js'],['es6-from-src-to-normal-js-in-public'])
})
gulp.task('default', ['es6-from-src-to-normal-js-in-public', 'watch'])