add loopback bundle generation methods
This commit is contained in:
83
gulpfile.js
83
gulpfile.js
@ -1,18 +1,49 @@
|
||||
var gulp = require('gulp'),
|
||||
path = require('path'),
|
||||
|
||||
// utils
|
||||
notify = require('gulp-notify'),
|
||||
debug = require('debug')('freecc:gulp'),
|
||||
bower = require('bower-main-files'),
|
||||
|
||||
// loopback client
|
||||
browserify = require('browserify'),
|
||||
boot = require('loopback-boot'),
|
||||
envify = require('envify/custom'),
|
||||
toVinylWithName = require('vinyl-source-stream'),
|
||||
|
||||
// server process
|
||||
nodemon = require('gulp-nodemon'),
|
||||
sync = require('browser-sync'),
|
||||
reload = sync.reload,
|
||||
|
||||
inject = require('gulp-inject'),
|
||||
reloadDelay = 1000,
|
||||
// css
|
||||
less = require('gulp-less'),
|
||||
path = require('path'),
|
||||
|
||||
// lint
|
||||
eslint = require('gulp-eslint');
|
||||
|
||||
|
||||
var reloadDelay = 1000;
|
||||
var reload = sync.reload;
|
||||
var paths = {
|
||||
server: './server/server.js',
|
||||
serverIgnore: []
|
||||
serverIgnore: [
|
||||
'gulpfile.js',
|
||||
'public/',
|
||||
'node_modules/'
|
||||
],
|
||||
publicJs: './public/js',
|
||||
|
||||
loopback: {
|
||||
client: './client/loopbackClient',
|
||||
root: path.join(__dirname, 'client/'),
|
||||
clientName: 'lbApp'
|
||||
},
|
||||
|
||||
syncWatch: [
|
||||
'public/**/*.*'
|
||||
]
|
||||
};
|
||||
|
||||
gulp.task('inject', function() {
|
||||
@ -23,6 +54,35 @@ gulp.task('inject', function() {
|
||||
.pipe(gulp.dest('views'));
|
||||
});
|
||||
|
||||
// NOTE(berks): not using this for now as loopback client is just too large
|
||||
gulp.task('loopback', function() {
|
||||
var config = {
|
||||
basedir: __dirname,
|
||||
debug: true,
|
||||
cache: {},
|
||||
packageCache: {},
|
||||
fullPaths: true,
|
||||
standalone: paths.loopback.clientName
|
||||
};
|
||||
|
||||
var b = browserify(config);
|
||||
|
||||
// compile loopback for the client
|
||||
b.require(paths.loopback.client);
|
||||
|
||||
boot.compileToBrowserify(paths.loopback.root, b);
|
||||
|
||||
// sub process.env for proper strings
|
||||
b.transform(envify({
|
||||
NODE_ENV: 'development'
|
||||
}));
|
||||
|
||||
return b.bundle()
|
||||
.on('error', errorNotifier)
|
||||
.pipe(toVinylWithName(paths.loopback.clientName + '.js'))
|
||||
.pipe(gulp.dest(paths.publicJs));
|
||||
});
|
||||
|
||||
gulp.task('serve', function(cb) {
|
||||
var called = false;
|
||||
nodemon({
|
||||
@ -57,7 +117,7 @@ gulp.task('sync', ['serve'], function() {
|
||||
sync.init(null, {
|
||||
proxy: 'http://localhost:3000',
|
||||
logLeval: 'debug',
|
||||
files: ['public/js/lib/*/*.{js, jsx}'],
|
||||
files: paths.syncWatch,
|
||||
port: 3001,
|
||||
open: false,
|
||||
reloadDelay: reloadDelay
|
||||
@ -85,3 +145,16 @@ gulp.task('watch', ['less', 'serve', 'sync'], function() {
|
||||
});
|
||||
|
||||
gulp.task('default', ['less', 'serve', 'sync', 'watch']);
|
||||
|
||||
function errorNotifier() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
|
||||
// Send error to notification center with gulp-notify
|
||||
notify.onError({
|
||||
title: 'Compile Error',
|
||||
message: '<%= error %>'
|
||||
}).apply(this, args);
|
||||
|
||||
// Keep gulp from hanging on this task
|
||||
this.emit('end');
|
||||
}
|
||||
|
@ -96,18 +96,22 @@
|
||||
"blessed": "~0.0.37",
|
||||
"bower-main-files": "~0.0.4",
|
||||
"browser-sync": "~1.8.1",
|
||||
"browserify": "^10.2.4",
|
||||
"chai": "~1.10.0",
|
||||
"envify": "^3.4.0",
|
||||
"eslint": "^0.21.2",
|
||||
"eslint-plugin-react": "^2.3.0",
|
||||
"gulp": "~3.8.8",
|
||||
"gulp-eslint": "~0.9.0",
|
||||
"gulp-inject": "~1.0.2",
|
||||
"gulp-nodemon": "^2.0.3",
|
||||
"gulp-notify": "^2.2.0",
|
||||
"istanbul": "^0.3.15",
|
||||
"loopback-explorer": "^1.7.2",
|
||||
"loopback-testing": "^1.1.0",
|
||||
"mocha": "~2.0.1",
|
||||
"multiline": "~1.0.1",
|
||||
"supertest": "~0.15.0"
|
||||
"supertest": "~0.15.0",
|
||||
"vinyl-source-stream": "^1.1.0"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user