-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
108 lines (93 loc) · 2.56 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var htmlreplace = require('gulp-html-replace');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var watchify = require('watchify');
var reactify = require('reactify');
var streamify = require('gulp-streamify');
var less = require('gulp-less');
var ospath = require('path');
var concat = require('gulp-concat');
var path = {
HTML: 'src/index.html',
LESS: 'src/less/main.less',
MINIFIED_OUT: 'build.min.js',
OUT: 'build.js',
DEST: 'dist',
DEST_BUILD: 'dist/build',
DEST_SRC: 'dist/src',
ENTRY_POINT: './src/js/App.js',
FRONTWISE_PATH: './src/js/frontwise-blocks/*.js',
VENDOR: './src/js/vendor/*.js'
};
gulp.task('copy', function(){
gulp.src(path.HTML)
.pipe(gulp.dest(path.DEST));
});
gulp.task('less', function() {
return gulp.src(path.LESS)
.pipe(less({
paths: [ ospath.join(__dirname, 'less', 'includes') ]
}))
.pipe(gulp.dest(path.DEST_SRC));
});
gulp.task('watch', function() {
gulp.watch(path.HTML, ['copy']);
gulp.watch(path.LESS , ['less']);
//gulp.watch(path.FRONTWISE_PATH, ['frontwise']);
var watcher = watchify(browserify({
entries: [path.ENTRY_POINT],
transform: [reactify],
debug: true,
cache: {}, packageCache: {}, fullPaths: true
}));
return watcher.on('update', function () {
watcher.bundle()
.pipe(source(path.OUT))
.pipe(gulp.dest(path.DEST_SRC))
console.log('Updated');
})
.bundle()
.pipe(source(path.OUT))
.pipe(gulp.dest(path.DEST_SRC));
});
gulp.task('build', function(){
browserify({
entries: [path.ENTRY_POINT],
transform: [reactify],
})
.bundle()
.pipe(source(path.MINIFIED_OUT))
.pipe(streamify(uglify(path.MINIFIED_OUT)))
.pipe(gulp.dest(path.DEST_BUILD));
});
gulp.task('buildsrc', function(){
browserify({
entries: [path.ENTRY_POINT],
transform: [reactify],
})
.bundle()
.pipe(source(path.OUT))
.pipe(gulp.dest(path.DEST_SRC));
});
gulp.task('replaceHTML', function(){
gulp.src(path.HTML)
.pipe(htmlreplace({
'js': 'build/' + path.MINIFIED_OUT
}))
.pipe(gulp.dest(path.DEST));
});
gulp.task('production', ['replaceHTML', 'build']);
// gulp.task('frontwise', function(){
// gulp.src(path.FRONTWISE_PATH)
// .pipe(concat('frontwise.js'))
// .pipe(gulp.dest(path.DEST_SRC));
// });
gulp.task('vendor', function(){
gulp.src(path.VENDOR)
.pipe(concat('vendor.js'))
.pipe(gulp.dest(path.DEST_SRC));
});
gulp.task('init', ['buildsrc', 'copy', 'less'])
gulp.task('default', ['watch']);