具有 angular 6 个更改的 Heroku 部署

Heroku deployment with angular 6 changes

我使用此快速代码部署了 angular 5 个应用程序。

const express = require('express');
const path = require('path');

const app = express();

app.use(express.static(__dirname + '/dist'));

app.get('/*', function(req,res) {
    
res.sendFile(path.join(__dirname+'/dist/index.html'));
});

app.listen(process.env.PORT || 8080);

但是在新的 angular 6 应用程序中,我们有 angular.json 而不是 angular.cli.json 和一些 outDir 选项以及 dist foler 位置的一些变化。 任何人都可以通过 angular 6 提出一些必要的更改建议。提前致谢

解决了!! 使用此代码 而不仅仅是 dist 你必须添加你的应用程序名称。

    const express = require('express');
const app = express();
const path = require('path');
app.use(express.static('./dist/myappname'));
app.get('/*', function(req, res) {
  res.sendFile(path.join('./dist/myappname/index.html'));
});
app.listen(process.env.PORT || 8080);