SIGN IN SIGN UP
[![taylor swift](https://img.shields.io/badge/secured%20by-taylor%20swift-brightgreen.svg)](https://twitter.com/SwiftOnSecurity)
2015-11-04 20:09:55 -08:00
[![volkswagen status](https://auchenberg.github.io/volkswagen/volkswargen_ci.svg?v=1)](https://github.com/auchenberg/volkswagen) [![GitHub version](https://badge.fury.io/gh/angularclass%2Fangular2-webpack-starter.svg)](http://badge.fury.io/gh/angular-class%2Fangular2-webpack-starter)
[![Dependency Status](https://david-dm.org/angularclass/angular2-webpack-starter.svg)](https://david-dm.org/angularclass/angular2-webpack-starter)
[![Issue Stats](http://issuestats.com/github/angularclass/angular2-webpack-starter/badge/pr?style=flat)](http://issuestats.com/github/angularclass/angular2-webpack-starter)
[![Issue Stats](http://issuestats.com/github/angularclass/angular2-webpack-starter/badge/issue?style=flat)](http://issuestats.com/github/angularclass/angular2-webpack-starter) [![Stack Share](http://img.shields.io/badge/tech-stack-0690fa.svg?style=flat)](http://stackshare.io/angularclass/angular-2-webpack-starter)
2015-07-12 04:57:25 -07:00
2015-05-17 22:04:24 -07:00
<p align="center">
2015-09-14 15:53:16 -07:00
<a href="https://angularclass.com" target="_blank">
<img src="https://cloud.githubusercontent.com/assets/1016365/9863762/a84fed4a-5af7-11e5-9dde-d5da01e797e7.png" alt="Webpack and Angular 2" width="500" height="320"/>
</a>
2015-05-17 22:04:24 -07:00
</p>
# Angular2 Webpack Starter [![Join Slack](https://img.shields.io/badge/slack-join-brightgreen.svg)](https://angularclass.com/slack-join) [![Join the chat at https://gitter.im/angularclass/angular2-webpack-starter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/angularclass/angular2-webpack-starter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2015-05-18 05:22:20 +00:00
2015-07-12 04:57:25 -07:00
2015-09-24 00:13:07 -07:00
> An Angular 2 starter kit featuring [Angular 2](https://angular.io) ([Router](https://angular.io/docs/js/latest/api/router/), [Forms](https://angular.io/docs/js/latest/api/forms/),
[Http](https://angular.io/docs/js/latest/api/http/),
2015-07-11 18:52:13 -07:00
[Services](https://gist.github.com/gdi2290/634101fec1671ee12b3e#_follow_@AngularClass_on_twitter),
2015-12-21 09:48:45 -08:00
[Tests](https://angular.io/docs/js/latest/api/test/), [E2E](https://angular.github.io/protractor/#/faq#what-s-the-difference-between-karma-and-protractor-when-do-i-use-which-)), [Karma](https://karma-runner.github.io/), [Protractor](https://angular.github.io/protractor/), [Jasmine](https://github.com/jasmine/jasmine), [Istanbul](https://github.com/gotwarlost/istanbul), [TypeScript](http://www.typescriptlang.org/), [Typings](https://github.com/typings/typings), and [Webpack](http://webpack.github.io/) by [AngularClass](https://angularclass.com).
> If you're looking for Angular 1.x please use [NG6-starter](https://github.com/angularclass/NG6-starter)
> If you're looking to learn about Webpack and ES6 Build Tools check out [ES6-build-tools](https://github.com/AngularClass/ES6-build-tools)
2015-09-24 00:13:07 -07:00
This seed repo serves as an Angular 2 starter for anyone looking to get up and running with Angular 2 and TypeScript fast. Using a [Webpack](http://webpack.github.io/) for building our files and assisting with boilerplate. We're also using Protractor for our end-to-end story and Karma for our unit tests.
* Best practices in file and application organization for Angular 2.
2015-05-23 01:06:32 -07:00
* Ready to go build system using Webpack for working with TypeScript.
2015-09-24 00:13:07 -07:00
* Angular 2 examples that are ready to go when experimenting with Angular 2.
* A great Angular 2 seed repo for anyone who wants to start their project.
* Testing Angular 2 code with Jasmine and Karma.
2015-12-21 09:48:45 -08:00
* Coverage with Istanbul and Karma
* End-to-end Angular 2 code using Protractor.
* Type manager with Typings
2015-03-07 22:47:37 -08:00
```coffeescript
2015-12-18 09:47:10 -08:00
Warning: Make sure you're using the latest version of Node.js and NPM
```
[Is Angular 2 Ready Yet?](http://splintercode.github.io/is-angular-2-ready/)
### Quick start
2015-08-23 21:11:52 -07:00
> Clone/Download the repo then edit `app.ts` inside [`/src/app/app.ts`](/src/app/app.ts)
2015-05-17 21:37:31 -07:00
2015-05-14 19:13:20 -07:00
```bash
# clone our repo
git clone https://github.com/angularclass/angular2-webpack-starter.git
# change directory to our repo
cd angular2-webpack-starter
2015-10-03 22:51:49 -07:00
# install the repo with npm
npm install
# install typescript typings
typings install
2015-10-03 22:51:49 -07:00
# start the server
npm start
```
2015-10-03 22:51:49 -07:00
go to [http://localhost:3000](http://localhost:3000) in your browser
# Table of Contents
* [File Structure](#file-structure)
* [Getting Started](#getting-started)
* [Dependencies](#dependencies)
* [Installing](#installing)
* [Running the app](#running-the-app)
* [Contributing](#contributing)
* [TypeScript](#typescript)
* [Frequently asked questions](#frequently-asked-questions)
* [Support, Questions, or Feedback](#support-questions-or-feedback)
* [License](#license)
2015-05-17 21:37:31 -07:00
## File Structure
We use the component approach in our starter. This is the new standard for developing Angular apps and a great way to ensure maintainable code by encapsulation of our behavior logic. A component is basically a self contained app usually in a single file or a folder with each concern as a file: style, template, specs, e2e, and component class. Here's how it looks:
```
2015-05-17 23:12:07 -07:00
angular2-webpack-starter/
├──src/ * our source files that will be compiled to javascript
2015-12-13 20:58:57 -08:00
| ├──bootstrap.ts * our entry file for our browser environment
│ │
2015-12-21 09:48:45 -08:00
| ├──polyfills.ts * our polyfills file for es6, es7, and zone.js
│ │
2015-12-13 20:58:57 -08:00
| ├──vendor.ts * our vendor file
│ │
│ ├──app/ * WebApp: folder
2015-12-13 12:26:07 -08:00
│ │ ├──app.spec.ts * a simple test of components in app.ts
│ │ ├──app.ts * App.ts: a simple version of our App component components
│ │ └──bootstrap.ts * entry file for app
│ │
2015-12-13 20:50:53 -08:00
│ └──public/ * static assets are served here
│ ├──favicon.ico * replace me with your own favicon.ico
│ ├──service-worker.js * ignore this. Web App service worker that's not complete yet
│ ├──robots.txt * for search engines to crawl your website
│ ├──human.txt * for humans to know who the developers are
│ │
│ └──index.html * Index.html: where we place our script tags
├──test/ * this is our global unit tests and end-to-end tests
2015-07-11 18:52:13 -07:00
2015-12-08 19:42:37 -08:00
├──spec-bundle.js * ignore this magic that sets up our angular 2 testing environment
2015-10-03 22:51:49 -07:00
├──karma.config.js * karma config for our unit tests
├──protractor.config.js * protractor config for our end-to-end tests
├──tsconfig.json * config that webpack uses for typescript
2015-12-13 20:50:53 -08:00
├──typings.json * our typings manager
├──package.json * what npm uses to manage it's dependencies
└──webpack.config.js * our webpack config
2015-05-14 19:13:20 -07:00
```
2015-03-07 22:47:37 -08:00
# Getting Started
## Dependencies
What you need to run this app:
2015-05-18 04:29:19 -07:00
* `node` and `npm` (`brew install node`)
2015-12-11 07:16:45 -08:00
* Ensure you're running the latest versions Node `v4.1.x`+ and NPM `2.14.x`+
2015-05-18 04:29:19 -07:00
Once you have those, you should install these globals with `npm install --global`:
* `webpack` (`npm install --global webpack`)
* `webpack-dev-server` (`npm install --global webpack-dev-server`)
* `karma` (`npm install --global karma-cli`)
* `protractor` (`npm install --global protractor`)
2015-12-13 20:50:53 -08:00
* `typings` (`npm install --global typings`)
* `typescript` (`npm install --global typescript`)
2015-05-17 23:18:14 -07:00
## Installing
2015-05-17 23:18:14 -07:00
* `fork` this repo
* `clone` your fork
* `npm install` to install all dependencies
* `typings install` to install necessary typings
* `npm run server` to start the dev server in another tab
## Running the app
2015-08-03 14:14:50 -07:00
After you have installed all dependencies you can now run the app. Run `npm run server` to start a local server using `webpack-dev-server` which will watch, build (in-memory), and reload for you. The port will be displayed to you as `http://localhost:3000` (or if you prefer IPv6, if you're using `express` server, then it's `http://[::1]:3000/`).
2015-05-14 19:13:20 -07:00
### server
2015-03-07 22:47:37 -08:00
```bash
2015-12-13 20:50:53 -08:00
npm run server # or either webpack-dev-server
2015-03-07 22:47:37 -08:00
```
2015-05-14 19:13:20 -07:00
## Other commands
### build files
```bash
2015-12-13 20:50:53 -08:00
npm run build
```
### watch and build files
2015-03-08 16:01:55 -07:00
```bash
2015-12-13 20:50:53 -08:00
npm run watch
```
### run tests
```bash
2015-12-13 20:50:53 -08:00
npm run test
```
### run webdriver (for end-to-end)
```bash
2015-12-13 20:50:53 -08:00
npm run webdriver-start
```
### run end-to-end tests
```bash
# make sure you have webdriver running and a sever for the client app
2015-12-13 20:50:53 -08:00
npm run e2e
2015-03-08 16:01:55 -07:00
```
2015-03-07 22:47:37 -08:00
# Contributing
2015-06-12 23:03:35 -04:00
You can include more examples as components but they must introduce a new concept such as `Home` component (separate folders), and Todo (services). I'll accept pretty much everything so feel free to open a Pull-Request
# TypeScript
2015-05-17 21:24:18 -07:00
> To take full advantage of TypeScript with autocomplete you would have to install it globally and use an editor with the correct TypeScript plugins.
## Use latest TypeScript compiler
2015-12-13 12:34:29 -08:00
TypeScript 1.7.x includes everything you need. Make sure to upgrade, even if you installed TypeScript previously.
2015-10-03 22:51:49 -07:00
```
npm install --global typescript
```
## Use a TypeScript-aware editor
We have good experience using these editors:
* [Visual Studio Code](https://code.visualstudio.com/)
* [Webstorm 10](https://www.jetbrains.com/webstorm/download/)
* [Atom](https://atom.io/) with [TypeScript plugin](https://atom.io/packages/atom-typescript)
* [Sublime Text](http://www.sublimetext.com/3) with [Typescript-Sublime-Plugin](https://github.com/Microsoft/Typescript-Sublime-plugin#installation)
# Frequently asked questions
* What's the current browser support for Angular 2 Alpha?
* Please view the updated list of [browser support for Angular 2](https://github.com/angularclass/awesome-angular2#current-browser-support-for-angular-2)
2015-12-09 09:41:15 -08:00
* Why is my service, aka provider, is not injecting parameter correctly?
2015-09-27 22:01:13 +02:00
* Please use `@Injectable()` for your service for typescript to correctly attach the metadata (this is a typescript beta problem)
2015-12-13 11:39:18 -08:00
* How do I run protractor with node 0.12.x?
* please check out this repo to use the old version of protractor https://github.com/AngularClass/angular2-webpack-starter/pull/146/files
* Where do I write my tests?
2015-12-09 09:41:15 -08:00
* You can write your tests anywhere you like in the `/src` directory next to your components or in the `test/` folder
* Is Angular 2 production ready yet?
* No, please visit [Is Angular 2 Ready Yet?](http://splintercode.github.io/is-angular-2-ready/) website.
* How do I start the app when I get `EACCES` and `EADDRINUSE` errors?
2015-08-02 10:24:07 -07:00
* The `EADDRINUSE` error means the port `3000` is currently being used and `EACCES` is lack of permission for webpack to build files to `./__build__/`
2015-07-05 18:42:39 -07:00
# Support, Questions, or Feedback
> Contact us anytime for anything about this repo or Angular 2
2015-05-17 22:21:08 -07:00
2015-12-09 09:41:15 -08:00
* [Chat: AngularClass.slack](http://angularclass.com/member-join/)
2015-05-17 22:21:08 -07:00
* [Twitter: @AngularClass](https://twitter.com/AngularClass)
2015-12-09 09:41:15 -08:00
* [Gitter: AngularClass/angular2-webpack-starter](https://gitter.im/angularclass/angular2-webpack-starter)
2015-05-17 22:21:08 -07:00
2015-07-12 17:28:27 -07:00
# Other Seed/Starter/Example Repos
* [angular2-webpack-starter (AngularClass)](https://github.com/angularclass/angular2-webpack-starter)
2015-12-09 09:41:15 -08:00
* Client/Server, Webpack, TypeScript, TSD, Protractor, Karma, Jasmine
2015-10-25 21:32:15 +00:00
* [ng2-play (Pawel Kozlowski)](https://github.com/pkozlowski-opensource/ng2-play)
2015-08-06 14:20:55 -07:00
* Client only, Minimalist, SystemJS, Gulp, TypeScript
2015-07-12 17:28:27 -07:00
* [angular2-seed (Minko Gechev)](https://github.com/mgechev/angular2-seed)
* Client only, SystemJS, Gulp, TypeScript, TSD, Versioned, Env Dev/Prod
2015-09-28 15:40:09 -07:00
* [ng2-lab (Roland Groza)](https://github.com/rolandjitsu/ng2-lab)
* Client only, ES6, TypeScript, Firebase, Gulp, Ci, TSD, TSLint
2015-07-12 17:28:27 -07:00
* [ng2-jspm-seed (Rob Wormald)](https://github.com/robwormald/ng2-jspm-seed)
* Client only, TypeScript, TSD, Gulp, JSPM, Minimalist
* [babel-angular2-app (Shuhei Kagawa)](https://github.com/shuhei/babel-angular2-app)
2015-12-13 12:03:59 -08:00
* Client only, Minimalist, Babel, ES6+, browserify
2015-05-17 22:21:08 -07:00
___
enjoy — **AngularClass**
2015-05-14 19:13:20 -07:00
<br><br>
2015-05-14 19:13:20 -07:00
2015-09-14 15:53:16 -07:00
[![AngularClass](https://cloud.githubusercontent.com/assets/1016365/9863770/cb0620fc-5af7-11e5-89df-d4b0b2cdfc43.png "Angular Class")](https://angularclass.com)
2015-05-14 19:13:20 -07:00
##[AngularClass](https://angularclass.com)
> Learn AngularJS, Angular 2, and Modern Web Development from the best.
2015-09-21 21:04:20 -07:00
> Looking for corporate Angular training, want to host us, or Angular consulting? patrick@angularclass.com
# License
2015-07-12 12:34:41 -07:00
[MIT](/LICENSE)