2017-09-05 13 views
0

lite-server가 기본 색인을 덮어 쓰려는 시도를 무시하고있는 것처럼 보입니다.lite-server가 bs-config.js에서 "server.index"무시를 인식하도록하는 올바른 방법입니까?

내가 BS-config.json 있습니다

{ 
    "server": { 
    "baseDir": "src", 
    "index": "/index.3.html", 
    "routes": { 
     "/node_modules": "node_modules" 
    } 
    } 
} 

나는 라이트 - 서버 버전 2.3.0을 사용하고,이 같은 : 위의 콘솔 로그 출력에서 ​​

> lite-server -c=bs-config.json 

browser-sync config ** 

{ injectChanges: false, 
    files: [ './**/*.{html,htm,css,js}' ], 
    watchOptions: { ignored: 'node_modules' }, 
    server: 
    { baseDir: 'src', 
    middleware: [ [Function], [Function] ], 
    directory: true, 
    index: '/index.3.html', 
    routes: { '/node_modules': 'node_modules' 
    } 
    } 
} 

를, 그것은 인식 bs-config.json index의 기본값은 "index.3.html"입니다. 그러나 브라우저에서 "GET http://localhost"을 요청하면 콘솔은 index.3.html 대신 index.html을 제공하려고 시도하고 있음을 보여줍니다. 나는 또한 BS-config.js을 공급 시도

[Browsersync] Serving files from: src 
[Browsersync] Watching files... 
17.09.04 22:35:51 404 GET /index.html 

:

"use strict"; 

module.exports = { 
    "server": { 
    "baseDir": "src", 
    index: "i/index.3.html", 
    "directory":true, 
    "routes": { 
     "/node_modules": "node_modules" 
    } 
    // middleware,: { 
    // // overrides the second middleware default with new settings 
    // 1: require('connect-history-api-fallback')({index: '/index.3.html', verbose: true}) 
    // } 
    } 
} 

와 함께 라이트 서버를 실행 :

> lite-server -c=bs-config.js 

하지만 동작은 동일합니다.

질문 : bs-config의 server.index를 라이트 서버로 대체하려면 어떻게합니까?

답변

0

lite-server의 config-default.js는 두 번째 미들웨어 "fallback"기능의 색인을 설정합니다. 이것은 bs-config 설정을 덮어 쓰는 것 같습니다.

그래서 솔루션은 미들웨어를 재정 의하여 원하는대로 인덱스를 설정합니다.

BS-config.js :

module.exports = { 
    "server": { 
    "baseDir": "src", 
    "routes": { 
     "/node_modules": "node_modules" 
    }, 
    middleware: { 
     // overrides the second middleware default with new settings 
     1: require('connect-history-api-fallback')({ 
      index: '/index.3.html', 
      htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'] // systemjs workaround}) 
    } 
    } 
} 

주 : 1. 라이트-Server의 이후 버전이 미들웨어 기능의 다른 인덱스 위치에 인덱스 대체를 넣어 그것의 기본 - 설정의 미들웨어를 변경하는 경우 배열 또는 다른 응답 헤더를 설정하려면이 bs-config 솔루션을 적절하게 변경해야합니다.

참조 : Browserync 문서 : https://browsersync.io/docs/options

라이트 - 서버 : https://github.com/johnpapa/lite-server