-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
74 lines (67 loc) · 2.13 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
// Copyright IBM Corp. 2015. All Rights Reserved.
// Node module: loopback-example-isomorphic
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
var gulp = require('gulp');
var del = require('del');
var rename = require('gulp-rename');
var browserify = require('browserify');
var boot = require('loopback-boot');
var path = require('path');
var fs = require('fs');
gulp.task('default', [
'clean',
'build:assets',
'build:lb-client',
'install'
]);
gulp.task('clean', function(done) {
del(['client/dist/**/*'], done);
});
gulp.task('build:assets', ['clean'], function() {
var assets = [
{src: 'angular/angular.js'},
{src: 'angular-resource/angular-resource.js'},
{src: 'angular-ui-router/release/angular-ui-router.js'},
{src: 'bootstrap/dist/css/bootstrap.css', dest: 'css'},
{src: 'bootstrap/dist/css/bootstrap.css.map', dest: 'css'},
{src: 'bootstrap/dist/fonts/glyphicons-halflings-regular.ttf',
dest: 'fonts'},
{src: 'bootstrap/dist/fonts/glyphicons-halflings-regular.woff',
dest: 'fonts'},
{src: 'bootstrap/dist/fonts/glyphicons-halflings-regular.woff2',
dest: 'fonts'},
{src: 'bootstrap/dist/js/bootstrap.js'},
{src: 'jquery/dist/jquery.js'}
];
assets.forEach(function(asset) {
var dest = 'client/public/';
dest += asset.dest ? asset.dest : 'vendor';
gulp.src('client/bower_components/' + asset.src)
.pipe(gulp.dest(dest));
});
});
gulp.task('build:lb-client', ['clean'], function(done) {
var b = browserify({basedir: path.resolve(__dirname, 'client/loopback')});
b.require(path.resolve(__dirname, 'client/loopback/index.js'),
{expose: 'lbclient'});
try {
boot.compileToBrowserify({appRootDir: path.resolve(__dirname,
'client/loopback')}, b);
} catch(e) {
throw e;
}
var target = fs.createWriteStream('client/public/js/bundle.js');
target
.on('error', done)
.on('close', done);
b.bundle().pipe(target);
});
gulp.task('install', [
'clean',
'build:assets',
'build:lb-client'
], function() {
gulp.src('client/public/**/*')
.pipe(gulp.dest('client/dist'));
});