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

2
  • 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." Commented Jun 13, 2016 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? Commented Jun 14, 2016 at 11:32

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

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 I'd just like to add that if you use the 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.
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.
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 (in case you haven't seen it yet)
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.