File tree 2 files changed +30
-2
lines changed 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 1
1
import express from 'express' ;
2
+ import fallback from 'express-history-api-fallback' ;
3
+ import path from 'path' ;
2
4
import app from './server/server' ;
3
5
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
5
28
app . on ( 'started' , ( ) => {
6
29
const baseUrl = app . get ( 'url' ) . replace ( / \/ $ / , '' ) ;
7
30
console . log ( 'Browse your CLIENT files at %s' , baseUrl ) ;
Original file line number Diff line number Diff line change 8
8
"scripts" : {
9
9
"lint" : " eslint ." ,
10
10
"dev" : " gulp serve" ,
11
- "build" : " gulp build" ,
11
+ "build" : " gulp build --production" ,
12
+ "afterbuild" : " cd build && npm install --production" ,
12
13
"test" : " gulp test" ,
13
14
"test:server" : " gulp test:server" ,
14
15
"test:client" : " gulp test:client" ,
21
22
"helmet" : " ^1.3.0" ,
22
23
"http-server" : " ^0.11.1" ,
23
24
"express" : " ^4.16.2" ,
25
+ "express-history-api-fallback" : " ^2.2.1" ,
24
26
"loopback" : " ^3.16.2" ,
25
27
"loopback-boot" : " ^2.27.0" ,
26
28
"loopback-component-explorer" : " ^4.0.0" ,
43
45
{{/extended }}
44
46
},
45
47
"devDependencies" : {
48
+ "aliasify" : " ^2.1.0" ,
46
49
"babel-core" : " ^6.25.0" ,
50
+ "babel-eslint" : " ^8.2.2" ,
47
51
"babel-plugin-transform-runtime" : " ^6.23.0" ,
48
52
"babel-preset-env" : " ^1.6.1" ,
49
53
"babel-preset-stage-2" : " ^6.24.1" ,
50
54
"babelify" : " ^7.3.0" ,
51
55
"browserify" : " ^14.4.0" ,
56
+ "browserify-global-shim" : " ^1.0.3" ,
52
57
"chai" : " ^4.1.0" ,
53
58
"chai-http" : " ^3.0.0" ,
54
59
"css-modulesify" : " ^0.28.0" ,
You can’t perform that action at this time.
0 commit comments