2017-11-09 9 views
1

anglecliで作成された2つの別々のAngularアプリがあります。どちらも、角度ユニバーサルを経由してnode.jsサーバーで実行するように既に変更されています(例:Angular's tutorial)。各アプリが異なるindex.htmlファイルを持っているので、私は2つのビューエンジンを作成する必要があると思いますが、どのように私は1つのルートにつのエンジンを使用するようにExpressを伝えることができ複数のAngular Universalアプリを1つのExpressアプリで提供

app.engine('html', (_, options, callback) => { 
    renderModuleFactory(AppServerModuleNgFactory, { 
    // Our index.html 
    document: template, 
    url: options.req.url, 
    // DI so that we can get lazy-loading to work differently (since we need it to just instantly render it) 
    extraProviders: [ 
     provideModuleMap(LAZY_MODULE_MAP) 
    ] 
    }).then(html => { 
    callback(null, html); 
    }); 
}); 

app.set('view engine', 'html'); 

の例では、ビューエンジンを作成し、別のルートで別のエンジンを使用していますか? つまり、app1/app1app2/app2にマップするにはどうすればよいですか?

答えて

1

Expressアプリケーションは、別のエンドポイントに複数のsub-applicationsをマウントすることができます。

const app1 = express(); 
const app2 = express(); 
... 
app.use('/app1', app1); 
app.use('/app2', app2); 
app.listen(3000); 

サブアプリケーションが独自の設定を持つことができますし、listen EDになるべきではありません。

関連する問題