Skip to content

Commit 3e33007

Browse files
committed
Change published directory when running in dist mode
1 parent b4d4f4d commit 3e33007

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"loopback-component-passport": "^1.1.2",
6868
"loopback-component-storage": "^1.0.6",
6969
"loopback-connector-mongodb": "^1.4.5",
70+
"minimist": "^1.1.0",
7071
"passport": "^0.2.0",
7172
"passport-facebook": "^1.0.3",
7273
"passport-google-oauth": "~0.1.5",

server/server.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ var loopback = require('loopback');
44
var boot = require('loopback-boot');
55
var path = require('path');
66
var app = module.exports = loopback();
7+
var argv = require('minimist')(process.argv.slice(2));
8+
79
/*
810
* body-parser is a piece of express middleware that
911
* reads a form's input and stores it as a javascript
@@ -115,7 +117,21 @@ app.get('/auth/logout', function (req, res, next) {
115117
// All static middleware should be registered at the end, as all requests
116118
// passing the static middleware are hitting the file system
117119
// Example:
118-
app.use(loopback.static(path.resolve(__dirname, '../client/app')));
120+
//app.use(loopback.static(path.resolve(__dirname, '../client/app')));
121+
122+
var dist = false;
123+
124+
var Static = null;
125+
126+
if (argv['dist'] === true) {
127+
Static = path.resolve(__dirname, '../dist/');
128+
}
129+
else {
130+
Static = path.resolve(__dirname, '../client/app');
131+
}
132+
133+
console.log("Static", Static);
134+
app.use(loopback.static(Static));
119135

120136
// Requests that get this far won't be handled
121137
// by any middleware. Convert them into a 404 error

0 commit comments

Comments
 (0)