File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 11import express from 'express' ;
2+ import fallback from 'express-history-api-fallback' ;
3+ import path from 'path' ;
24import app from './server/server' ;
35
4- app . use ( express . static ( 'client' ) ) ;
6+ const client = path . resolve ( __dirname , 'client' ) ;
7+
8+ const unless = function ( paths , middleware ) {
9+ return function ( req , res , next ) {
10+ if ( paths . some ( p => req . path . indexOf ( p ) > - 1 ) ) {
11+ return next ( ) ;
12+ }
13+
14+ return middleware ( req , res , next ) ;
15+ } ;
16+ } ;
17+
18+ // add static route for client
19+ app . use ( express . static ( client ) ) ;
20+
21+ // enable redirect urls to index
22+ app . use ( unless (
23+ [ '/api' , '/explorer' ] ,
24+ fallback ( 'index.html' , { root : client } ) ,
25+ ) ) ;
26+
27+ // start app
528app . on ( 'started' , ( ) => {
629 const baseUrl = app . get ( 'url' ) . replace ( / \/ $ / , '' ) ;
730 console . log ( 'Browse your CLIENT files at %s' , baseUrl ) ;
Original file line number Diff line number Diff line change 88 "scripts" : {
99 "lint" : " eslint ." ,
1010 "dev" : " gulp serve" ,
11- "build" : " gulp build" ,
11+ "build" : " gulp build --production" ,
12+ "afterbuild" : " cd build && npm install --production" ,
1213 "test" : " gulp test" ,
1314 "test:server" : " gulp test:server" ,
1415 "test:client" : " gulp test:client" ,
2122 "helmet" : " ^1.3.0" ,
2223 "http-server" : " ^0.11.1" ,
2324 "express" : " ^4.16.2" ,
25+ "express-history-api-fallback" : " ^2.2.1" ,
2426 "loopback" : " ^3.16.2" ,
2527 "loopback-boot" : " ^2.27.0" ,
2628 "loopback-component-explorer" : " ^4.0.0" ,
4345 {{/extended }}
4446 },
4547 "devDependencies" : {
48+ "aliasify" : " ^2.1.0" ,
4649 "babel-core" : " ^6.25.0" ,
50+ "babel-eslint" : " ^8.2.2" ,
4751 "babel-plugin-transform-runtime" : " ^6.23.0" ,
4852 "babel-preset-env" : " ^1.6.1" ,
4953 "babel-preset-stage-2" : " ^6.24.1" ,
5054 "babelify" : " ^7.3.0" ,
5155 "browserify" : " ^14.4.0" ,
56+ "browserify-global-shim" : " ^1.0.3" ,
5257 "chai" : " ^4.1.0" ,
5358 "chai-http" : " ^3.0.0" ,
5459 "css-modulesify" : " ^0.28.0" ,
You can’t perform that action at this time.
0 commit comments