avanwieringen
avanwieringen

Reputation: 2444

Angular 4/5 simply client side for portability?

I once fumbled a bit with Angular 1 for some hobby project and I just had a simple html page and some js files and was done.

Now I want to continue again and stumble upon Angular 4/5. It looks nice and interesting, but to me appears that all the examples use the Angular CLI together with Express / Node. And so the most simple example requires me to run a web server. Even if I don't have any serverside interaction I need a webserver. Am I overlooking something or is it impossible to just have a HTML file with some (precompiled by Angular) JS files in order to make it very portable?

Mind, I am not developing for some professinal business. Just an enthousiast that likes to tinker and create it's own stuff.

Upvotes: 1

Views: 138

Answers (1)

Z. Bagley
Z. Bagley

Reputation: 9270

You're overlooking a few items and missing some pieces, mainly:

  • Angular-CLI and npm are for development, and not for direct deployment.
  • After building a project with Angular CLI you can use the command ng build to create a dist bundle which will contain your single web page and javascript + assets.
  • You can host the items inside the dist folder after building a project on any server with minimal tweaks (even apache, but you need to edit the .htaccess file to forward route params).

If you create a new project with Angular CLI with ng new project-name, you can immediate type ng build and see the results of a single index.html along with the javascript files.

Upvotes: 1

Related Questions