I'm trying to configure a express server using Angular 2, in many configuration examples I saw the angular-cli.json being changed in the main configuration pointing to a server.js file.
But when I change it, the application doesn't start on ng serve.
I would have to call the main.ts file inside of the server.js? How?
Ex:
"main": "main.ts"
"main": "server.ts"
My express server is very simple, I used as base the following: https://tableless.com.br/criando-uma-aplicacao-de-chat-simples-com-nodejs-e-socket-io/
To reiterate from above, you are just going to build your project using the proxy for local development following the - cli proxy docs.
If you do something like
ng serve --host 0.0.0.0 --proxy-config proxy.conf.json
with your proxy.conf.json
{
"/api": {
"target": "http://localhost:3000",
"secure": false
}
}
For express as your server you will send a route back to the dist/index file with something like -
app.all('/*', function(req, res) {
res.sendFile( DIST +'/index.html');
});