我有一个node.js应用程序设置为使用typescript。该应用程序应该部署在heroku上。node.js应用程序被设置为restful api,用于身份验证、注册和请求。
我想知道我需要添加哪些依赖项才能开始在同一项目中构建angular 4应用程序。
我在github上发现了一个问题,建议使用ng init,但这不再是一个选项。ng new会创建一个全新的项目目录,而不是添加依赖项和文件。
这里还有另一个问题,操作员将他自己的答案标记为正确,基本上是“使用流星”。
编辑:我知道如何在本地工作时从node.js应用程序中同时提供angular 2+应用程序,只需构建并提供index.ts文件即可。但是,我怎样才能让angular开发文件与git中的node.js文件共存,这样我才能编译并部署它们呢?
发布于 2017-07-11 15:30:15
我也有同样的情况,我在heroku上有一个解析服务器,并想用Angular对其进行分组。
在server.js文件中:
app.use(express.static(__dirname + '/dist'));(你只需要快速)
我还使用了国际化,所以我做了一些快速的东西(早期阶段,请不要评判):
app.get('/', function(req, res) {
let userLanguage = req.headers["accept-language"];
let langs = ['fr', 'en'];
let preferred = userLanguage.substr(0, 2).toLowerCase();
console.log('User\'s preferred language is ' + preferred.toUpperCase());
if (langs.indexOf(preferred) >= 0) { res.redirect(preferred); } else { res.redirect('/en'); }
});我的NG命令:
"postinstall": "npm run build-i18n",
"i18n": "ng xi18n --output-path src/i18n --out-file messages.xlf",
"build-i18n:fr": "ng build --output-path=dist/fr --aot --prod --bh /fr/ --i18n-file=src/i18n/messages.fr.xlf --i18n-format=xlf --locale=fr",
"build-i18n:en": "ng build --output-path=dist/en --aot --prod --bh /en/ --i18n-file=src/i18n/messages.en.xlf --i18n-format=xlf --locale=en",
"build-i18n": "npm run build-i18n:en && npm run build-i18n:fr"我的应用程序构建在两个文件夹中,用于实际的两种语言,当用户访问应用程序时,会被重定向到这两种语言之一。
https://stackoverflow.com/questions/45025709
复制相似问题