forked from MarcosRava/model-structure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
50 lines (38 loc) · 1.08 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
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var refresh = require('gulp-livereload');
var lr = require('tiny-lr');
var server = lr();
var __BUILD = false;
function showError(e) {
console.log('\n===\n');
console.log('\033[31m Error:\033[0m \n');
console.log('\033[1m' + e.message + '\033[0m');
console.log('\n===\n');
}
gulp.task('scripts', function () {
gulp.src(['./index.js'])
.pipe(browserify())
.on('error', showError)
.pipe(concat('model-structure.js'))
.pipe(gulp.dest('./dist/'))
.pipe(uglify())
.pipe(concat('model-structure-min.js'))
.pipe(gulp.dest('./dist/'))
.pipe(refresh(server));
});
gulp.task('lr-server', function () {
server.listen(35710, function (err) {
if (err) return console.log(err, err.stack);
});
});
gulp.task('default', ['scripts', 'lr-server'], function () {
gulp.watch(['./src/**'], ['scripts']);
});
gulp.task('build', function () {
__BUILD = true;
gulp.run('scripts');
});