Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hosting Angular 2 app

I'm new to Angular 2, I know host Angular 1.x on shared hosting like GoDaddy, but I don't have idea how publish Angular 2 application, for example I have this structure folder:

angular2-quickstart

--app
  app.component.ts
  main.ts

--node_modules

--typings

index.html
package.json
styles.css
systemjs.config.js
tsconfig.json
typings.json

What file i need to upload on ftp?

I don't tried anything because I don't know how to proceed
Thanks in advance!

like image 362
user1608228 Avatar asked Jun 13 '16 09:06

user1608228


People also ask

Where can I host my Angular app?

Because these files are static, you can host them on any web server capable of serving files; such as Node. js , Java, . NET, or any backend such as Firebase, Google Cloud, or App Engine.

Can Angular run on shared hosting?

import { LocationStrategy, PathLocationStrategy } from '@angular/common'; Now execute ng build --prod once more and upload the new distribution files to your shared server — everything should now work! That is all you need to begin working with Angular on your very own shared hosting server.

Can I host Angular app in cPanel?

You can have Angular up and running on your web site in minutes by using the Softaculous application installer in cPanel.


2 Answers

Well, you can run ng build in your root application directory. It will create a dist directory containing the app and files. You can put this directory into the page the webserver will look for the index.html

like image 123
Max Avatar answered Oct 14 '22 06:10

Max


As a component based language, angular 2 includes some caveats in it's deployment process. First, the files used in development environment aren't necessarily shipped to production. In short, you'll only need to upload .js, .html and .css files .

Second is that even if your application works deploying only the files mention above, it's advisable to include the following process:

Bundling: Compiling all the .js files into single files. For instance, vendor.js could include all third party libs and bundle.js would include all application .js files. (Bundles are import for performance reasons, but bear in mind that with the arrival of http 2, this process will be abandoned)

Minification: it's a standard process in all web apps, but now you only minify bundled files.

Take a look in this article, as it give some examples of tools that can help you with deployment process. http://www.ninjaducks.in/hacking/angular-setup/

like image 28
Daniel Pliscki Avatar answered Oct 14 '22 04:10

Daniel Pliscki