背景:我将构建40多个应用程序的语言环境,并将所有页面预先呈现为静态HTML。
为此,我需要访问每个AppServerModuleNgFactory
。
1-我可以使用节点@angular/cli
在名为build.ts
的文件中调用来自exec
包的ng build吗?
来自:
exec(ng build --output-path=dist/apps/portfolio/fr-CA -prod --aot --bh=/fr-CA/ --app=portfolio --i18n-file=./apps/portfolio/i18n/messages.fr-CA.xlf --i18n-format=xlf --locale=fr-CA;)
const { AppServerModuleNgFactory} = require('dist/apps/portfolio-server/fr-CA/main.bundle.js');
更好的 :
const { AppServerModuleNgFactory} = await ng.build(`
-prod
--aot
--bh=/fr-CA/
--app=portfolio
--i18n-file=./apps/portfolio/i18n/messages.fr-CA.xlf
--i18n-format=xlf
--locale=fr-CA`);