3

Some questions to put angular2 web project to production environment

  1. We do development on lite server but what is best for production? Is is some other server module of nodejs? Technically we can have any server (apache, tomcat, etc).
  2. How should we do source code management for below context.
    • browser must include js files so project should have js files when deployed
    • In standard java project we just commit .java files and uses jenkins (may be other tools) to compile and make the deploy-able structure
    • Should we follow same strategy here? i.e. don't commit compiled js files and deploy using some node compiler which takes ts files and compiles it to js
  3. What is the best way to minify/obfuscate the js files
    • I know a way using outDir and outFile with grump but I don't want every files tobe included in one minified file because it kills the concept of lazy loading
    • Is there a way to minify and obfuscate js files on compile time only?
  4. What enableProdMode() do? How it is different than not using it?
Akshay
  • 3,558
  • 4
  • 43
  • 77
  • Can't comment on all of the above, but I changed from lite-server to express and it was a very easy transition. With node you can always write your own server without using a node module. – user2263572 Apr 06 '16 at 13:47

1 Answers1

1

Here are some answers to your questions:

  1. Angular2 applications only consist of static files so they can be serve by any static Web servers or server applications that can define static folders (Express, ...)

  2. Regarding source code management, you must have a packaging phase to optimize the application loading (gater files, uglify, ...). Your source code must contain your TypeScript files (or JS files if using ES5 or ES6). Such packaging can be done using Gulp for example. Your Jenkins server will be able to checkout the source code, build it and execute tests.

  3. In fact, when not using the outFile property of the TypeScript compiler, you won't be able to gather all the JS compiled files into a single one since anonymous modules will be created within each JS files.

    See this question for more details of this:

  4. Regarding prod mode, here is an extract of the documentation:

    Disable Angular's development mode, which turns off assertions and other checks within the framework.

    One important assertion this disables verifies that a change detection pass does not result in additional changes to any bindings (also known as unidirectional data flow).

Community
  • 1
  • 1
Thierry Templier
  • 198,364
  • 44
  • 396
  • 360
  • What I am using is AOT compiler with apache http server for PROD and JIT compiler and lite-server for development – Akshay Jan 24 '17 at 14:27