-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
10 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
// importa express | ||
const express = require("express"); | ||
|
||
// inicia express | ||
const app = express(); | ||
|
||
// nome da pasta dentro de dist que sera feito build, ver angular.json | ||
const appName = "curso-angular-basico"; | ||
|
||
// local onde build ira gerar os arquivos | ||
const outputPath = `${__dirname}/dist/${appName}`; | ||
|
||
// seta o diretorio de build para servir o conteudo estatico | ||
app.use(express.static(outputPath)); | ||
|
||
// qualquer requisicao sera direcionada para o index.html no diretorio de build | ||
app.get("/documentation", (req, res) => { | ||
res.sendFile(`${__dirname}/documentation/index.html`); | ||
}); | ||
|
||
// qualquer requisicao sera direcionada para o index.html no diretorio de build | ||
app.get("/*", (req, res) => { | ||
res.sendFile(`${outputPath}/index.html`); | ||
}); | ||
|
||
// express vai ouvir na porta que o Heroku disponibilizar | ||
app.listen(process.env.PORT); |