简体   繁体   English

准备Web应用程序生产(angularjs / nodejs)

[英]Getting web application production ready (angularjs/nodejs)

My web application consists of angularjs on front end side and nodejs server listening to client requests. 我的Web应用程序由前端的angularjs和侦听客户端请求的nodejs服务器组成。 This is my folder structure: Folder Structure 这是我的文件夹结构: 文件夹结构

UX contains client side code and IT contains server side code. UX包含客户端代码,IT包含服务器代码。 I am using gulp to watch over development changes and for packaging (you can see the dist folder in UX). 我正在使用gulp监视开发更改和打包(您可以在UX中看到dist文件夹)。 I use two terminals to launch this web application locally. 我使用两个终端在本地启动此Web应用程序。 From one terminal, I use gulp serve (UX folder) to start a static UI server which monitors the changes as I make to UI and reflect back the changes on the browser immediately. 从一个终端,我使用gulp serve (UX文件夹)启动了一个静态UI服务器,该服务器监视对UI所做的更改,并立即在浏览器中反映出更改。 From the second terminal, I start a node server2.js server. 从第二个终端,我启动一个node server2.js服务器。

The UX/src/app folder has a config file where I specify server ip address and app.js uses this info to connect to server (currently). UX / src / app文件夹有一个配置文件,我在其中指定服务器ip地址,而app.js使用此信息连接到服务器(当前)。

Now, I want to deploy this app over cloud. 现在,我想在云上部署此应用程序。 On the cloud, I have to specify a node it/server2.js as a starting point in its config file. 在云上,我必须在其配置文件中指定一个node it/server2.js作为起点。 Hence, I want the corresponding web link should point to index.html in UX/src/app folder. 因此,我希望相应的Web链接应指向UX / src / app文件夹中的index.html。

Hence, I need some advice on how to integrate my client side app.js file in the server2.js file on server side. 因此,我需要一些有关如何将客户端app.js文件集成到服务器端的server2.js文件中的建议。

I am an amateur. 我是一个业余爱好者。

Thanks a lot! 非常感谢!

I added this code to my server2.js file: 我将此代码添加到了server2.js文件中:

var express = require("express");
var app = express();
app.use(express.static("ux/dist/"));

app.get("/", function(req, res, next){
    res.sendFile('index.html');
});

Currently, it is invoking index.html page from UX folder. 当前,它正在从UX文件夹调用index.html页面。 But, I am not sure whether I have done it the ideal way. 但是,我不确定我是否以理想的方式做到了。 Need help on this. 需要帮助。

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

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