6

I created a project using the Angular2 quickstart https://angular.io/docs/js/latest/quickstart.html

I changed it completely to do my things, some usage of webcams, indexedDB and things like that :-).

The thing right now is that I've been using npm as the site recommends and it feels wrong now just changing to Gulp to create a build, instead of creating a build script on npm.

The next issue is that I've never done such a thing and I'm completely lost... do you know of any build script I could use/adapt? Or should I switch to Gulp?

Thank you

RollWhisTler
  • 341
  • 1
  • 3
  • 10
  • What do you mean by creating a production build? Are you talking about stopping the `"Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode."` – Gab Jun 13 '16 at 14:49
  • Thank you for commenting Gabriele, I don't quite follow. I guess running in production mode would change some ways in which angular 2 behaves, things it tracks down or performance improvements, whatever. I don't think it will provide me with an index.html with a vendor.js and an app.js minified and all that, you know what I mean? – RollWhisTler Jun 14 '16 at 11:32

2 Answers2

3

I see, now I think I understand where the misunderstanding is. The link you provided is for Angular2 using Javascript. The best way to create a production Angular2 build is to use Typescript (and I believe it's the only officially supported way at this point as well). Here is a link to the tutorial using Typescript. If you don't know what that is, here's a SO question on it.

Once you learn how to use Angular2 with Typescript, I recommend reading this article on Angular2 in production.

Also, they are currently working on a command-line interface that will automatically build your app for production. They've released it but it's buggy at this point.

Community
  • 1
  • 1
Gab
  • 1,007
  • 9
  • 22
  • I'll check it out, thank you! I'm already using typescript, sorry for the wrong link. I think creating a npm script that uses the typescript to get all required js (vendor and custom) together would be awesome, but couldn't find anything about it, I guess is not trivial :-). I let this open some more days in case we get a "better" answer, if not I'll mark yours and try to build something myself, if I succed I'll post here again. – RollWhisTler Jun 15 '16 at 15:53
  • @RollWhisTler I'd just like to add that if you use the [angular-cli](https://github.com/angular/angular-cli), you can run `ng build -prod` and it will turn your project into just html and css and 1 js file that holds all the code for the project. It increases performance significantly. – Gab Jun 27 '16 at 14:01
  • Yes, sadly angular-cli is not updated to latest @angular dependencies notation, or it wasn't last time I checked. I want to take a look at webpack. – RollWhisTler Jun 28 '16 at 15:10
  • 1
    The dependencies have been updated to RC3 (I updated the cli yesterday). If you want to use webpack, here's the [documentation for using webpack from the angular website](https://angular.io/docs/ts/latest/guide/webpack.html) (in case you haven't seen it yet) – Gab Jun 29 '16 at 13:14
0

Might I suggest my project Zwitterion. Zwitterion is a server that allows you to include TypeScript files directly in the browser, and will automatically transpile all imported modules in your application. To do a production build, you run Zwitterion with the --build-static command. It's extremely simple, and if you'd like to learn more check out the article or the GitHub repo.

lastmjs
  • 924
  • 3
  • 11
  • 22