如何正确部署 angular 应用程序(基于 ngBoilerplate 并使用 nginx)?

How to properly deploy angular application (based on ngBoilerplate and using nginx)?

我发现,ngBoilerplate 在基于 angular 的基础上迈出 Web 开发的第一步非常容易。正确知道我正在尝试准备我的部署管道,所以我使用 github、travis-ci 和 dockerized nginx 图像。

我认为要正确部署我的简单 angular 网站,我只需要:

git clone https://github.com/ngbp/ngbp.git
cd ngbp/
npm install
bower install
grunt compile

然后复制bin/目录:

bin/
├── assets
│   ├── ngbp-0.3.2.css
│   ├── ngbp-0.3.2.js
│   └── README.md
└── index.html

到 nginx 目录 /usr/share/nginx/html/.

不幸的是,javascript 代码有问题。我收到错误

Error: $injector:nomod
Module Unavailable

https://docs.angularjs.org/error/$injector/nomod?p0=ngBoilerplate.home

我做错了什么?

在 ngbp 中,G运行t 任务分为 two categories:构建和编译。构建任务完成 运行 站点所需的一切,特别是在开发过程中,编译任务连接和缩小生产文件。

你的问题是你没有运行编译任务运行所需的构建任务。为了节省时间(见上文link),这些是分开的。如果要从头到尾,包括缩小,只需 运行 grunt,相当于 运行ning grunt build compile.

README 假定您使用 grunt buildgrunt watch 进行所有开发,之后您可以在部署之前简单地 运行 grunt compile