2

I'm learning Angular 2 - I just finished the official Tour Of Heroes tutorial (https://angular.io/docs/ts/latest/tutorial/) and built my own website with weather just for training.

The whole application from the tutorial was built using NodeJS, which, as I understand it, is used to run javascript files. But, what if I want to upload my website to a server (one of the free hostings) to see how it looks like on my other devices (mobile, tablet, etc.)?

Without angular, I wouldn't have problems with that - I'd just use FTP client to upload my .html, .css and .js files to the hosting. But how should I do it with angular2 application? In my project's directory there are folders like: node_modules, typings - they contain a lot of files, and I'm not sure if they are needed. I know that browsers do not support TypeScript (which I'm using), so I should only upload .js files, but how exactly should it be? Which files should I upload?

I tried uploading everything but node_modules and typings folders, but I just got "Loading..." when I tried accessing the website.

I saw this: Hosting Angular 2 app and there people just said to upload every js file, which I did.

Here's the link to my website: http://myweatherapp.comxa.com

//EDIT All the above can be represented by this one question: What are the steps to transform local angular2-quick-start-app into a website, which can be uploaded to any web-hosting?

Community
  • 1
  • 1
Loreno
  • 668
  • 8
  • 26
  • 1
    One way is you can use **webpack** along with **babel** to bundle and transpile the code into one JS, like index.js. Then you will only have to upload your views and css and index.js file to the server. – Nivesh Oct 03 '16 at 13:32
  • I'd rather like to upload my website without implementing new packages to it. isn't that possible? – Loreno Oct 03 '16 at 13:41
  • OK, so is there any guide (I can't find it), which would show me the steps to transform my local nodeJS angular 2 app (like quickstart app from angular2 tutorial) into a website, which I could just upload to a hosting? I'm new to all this stuff and I don't really know how to do it. Another thing: when I'm running my app with NodeJS, i have tsconfig.json, and there is target: "es5" - isn't that enough to get js files, that internet browsers would understand? – Loreno Oct 03 '16 at 13:57
  • check this out hope it clears your doubt http://stackoverflow.com/a/35563542/2680461 – Nivesh Oct 03 '16 at 14:33

1 Answers1

1

Take a look at Angular-Cli.

They make it so easy to build/bundle Angular 2 apps. They include a ng build and ng build:prod commands to build the angular 2 project into a distribution folder, standalone web app, so you can put it in a tomcat instance or anywhere and not just in a NodeJS environment.

Angular-Cli provides everything one could want when building an Angular 2 app. Take a look at their Table of Contents. The Build section is probably what you are more interested in

I use Angular-Cli and I absolutely love it.

Logan H
  • 3,383
  • 2
  • 33
  • 50