-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
56 lines (51 loc) · 1.62 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
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var buffer = require('vinyl-buffer');
var source = require('vinyl-source-stream');
var through = require('through2');
//var babelify = require('babelify');
var browserify = require('browserify');
var sourcemaps = require('gulp-sourcemaps');
var reactify = require('reactify');
//var webpack = require('webpack');
//var path = require('path');
//var loader = require('babel-loader');
// list every javascript source file here.
var scripts_sources = [
'./src/campaigns/static/js/main.js'
];
//
//gulp.task("webpack", function(callback) {
// // run webpack
// webpack({}, function(err, stats) {
// if(err) throw new gutil.PluginError("webpack", err);
// gutil.log("[webpack]", stats.toString({
// // output options
// }));
// callback();
// });
//});
gulp.task('scripts', function () {
// set up the browserify instance on a task basis
var b = browserify({
entries: scripts_sources,
debug: true,
// defining transforms here will avoid crashing your stream
transform: [reactify]
});
return b.bundle()
.pipe(source('scripts.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
// Add transformation tasks to the pipeline here.
//.pipe(uglify())
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./src/campaigns/static/dist/js/'));
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch(scripts_sources, ['scripts']);
//gulp.watch('scss/*.scss', ['sass']);
});