简体   繁体   English

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

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

I have found, that ngBoilerplate was extremly easy for making first steps in webdevelopment based on angular. 我发现ngBoilerplate非常容易在基于角度的Web开发中迈出第一步。 Right know I am trying to prepare my deployment pipeline, so I use github, travis-ci and dockerized nginx image. 知道我正在尝试准备部署管道,所以我使用github,travis-ci和dockerized nginx映像。

I thought that to properly deploy my simple angular website I just have to: 我认为要正确部署我的简单角度网站,我只需要:

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

and then copy bin/ directory: 然后复制bin/目录:

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

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

Unfortunately, something is wrong with javascript code. 不幸的是,javascript代码出了点问题。 I got error 我有错误

Error: $injector:nomod
Module Unavailable

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

What am I doing wrong? 我究竟做错了什么?

In ngbp, Grunt tasks are broken into two categories : build and compile. 在ngbp中,Grunt任务分为两类 :构建和编译。 The build task does everything needed to run the site, particularly while developing, and the compile task concatenates and minifies files for production. 构建任务完成了运行站点所需的一切,特别是在开发过程中,并且编译任务将文件合并并缩小了以供生产。

Your problem here is that you aren't running the build task, which the compile task needs in order to operate. 这里的问题是您没有运行构建任务,而编译任务需要运行该任务才能进行操作。 To save time (see above link), these are separate. 为了节省时间(请参见上面的链接),这些是分开的。 If you want to go from start to finish, including minification, just run grunt , which is equivalent to running grunt build compile . 如果要从头到尾(包括缩小)进行操作,只需运行grunt ,等效于运行grunt build compile

The README assumes that you do all your development with grunt build and grunt watch , after which you can simply run grunt compile before you deploy. README假定您使用grunt buildgrunt watch进行所有开发,然后您可以在部署之前简单地运行grunt compile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM