问题描述:

Using angular-cli, i created a new starter app. ng new my-app. Then i did ng serve and it worked fine on localhost:4200. Next, i used ng build and it created a dist folder with the created app.

I'm using the latest angular-cli and it uses webpack.

Now, i want to use the app in a local environment using node (If that's possible. If it's not, then i guess on WAMP in which i will write a php backend api). I am on a windows 10 machine right, 64 bit.

What are the next steps? I am new to nodejs hosting setup.

Eventually, i want to create a small app for my office to handle administrative work. It will be used by about 12-15 people all connected in a local network.

I am new to nodejs hosting setup.

网友答案:

you can use express with node.js and serve your dist content as static content with something like this (didn't test it but should work, I did something similar in another project):

var express = require('express');
var app = express();

app.use(express.static('dist'));

var server = app.listen(8080, function () {
   var host = server.address().address
   var port = server.address().port
   console.log("Example app listening at http://%s:%s", host, port)
})

if you want to do it just for development purpose, in my opinion you can setup a different flow using server designed ad hoc to recompile\reload the application when you change the code, without building every time and run the node.js server (much slow development flow). I personally use webpack-dev-server with webpack.

相关阅读:
Top