[英]Angular PreRendering / Ng Universal deployment
Is it really necessary to copy the node_modules upon deploy?部署时真的有必要复制 node_modules 吗? What is normally a 7 minute compile/run unit tests/deploy to the staging environment becomes a 40 minute process due to the 840 node modules we've got (running Angular 7 + Material + Ng-Select).
由于我们拥有 840 个节点模块(运行 Angular 7 + Material + Ng-Select),通常需要 7 分钟编译/运行单元测试/部署到登台环境的过程变成了 40 分钟的过程。 The issue comes down to system I/O of the nearly 100k tiny files.
问题归结为近 100k 个小文件的系统 I/O。
I'm trying to figure out a way to keep SSR, but it's becoming a losing battle when developers are waiting most of an hour to see their changes in the staging environment.我试图找出一种方法来保持 SSR,但是当开发人员等待大部分时间来查看他们在暂存环境中的变化时,这将成为一场失败的战斗。
Is there a way to bundle and minify the node modules into the main.server.ts file, perhaps?有没有办法将节点模块捆绑并缩小到 main.server.ts 文件中,也许?
You should only have to move the /dist
folder contents to your deploy area.您只需要将
/dist
文件夹内容移动到您的部署区域。 Depending on the version of Universal, a /dist/server
and /dist/browser
should be generated with the needed contents.根据 Universal 的版本,应该生成包含所需内容的
/dist/server
和/dist/browser
。
The server.js
that's produced is normally rather large as it contains most of your application and needed dependencies for use in the rendering process.生成的
server.js
通常相当大,因为它包含您的大部分应用程序和在渲染过程中使用所需的依赖项。
For instance, this is a quick'n'dirty example Dockerfile例如,这是一个简单的例子 Dockerfile
FROM node:12-alpine
WORKDIR /app
COPY ./dist /app/dist
EXPOSE 4000
CMD ["node", "/app/server"]
Note I left the target directory as dist
-- if changing this folder, I believe the matching change needs done in server.ts
:请注意,我将目标目录保留为
dist
- 如果更改此文件夹,我相信匹配更改需要在server.ts
中完成:
const distFolder = join(process.cwd(), 'dist/{app}/browser');
It looks at /dist
relative to where the current working directory ( WORKDIR
) was when starting the node process.它在启动节点进程时查看
/dist
相对于当前工作目录 ( WORKDIR
) 所在的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.