You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project is an application skeleton for a typical [AngularJS](http://angularjs.org/) web app.
4
-
You can use it to quickly bootstrap your angular webapp projects and dev environment for these
5
-
projects.
3
+
This project is an application skeleton for [AngularJS](http://angularjs.org/) 1.5 web app using new component syntax and typescript.
6
4
7
-
The seed contains a sample AngularJS application and is preconfigured to install the Angular
8
-
framework and a bunch of development and testing tools for instant web development gratification.
9
-
10
-
The seed app doesn't do much, just shows how to wire two controllers and views together.
5
+
It uses two different budnling systems webpack and systemjs, use the appropriate branch.
11
6
7
+
Webpack branch has support for importing sass styles inline in the modules, for system js external stylesheets should be used, it has support for inline imports only with jspm.
12
8
13
9
## Getting Started
14
10
15
-
To get you started you can simply clone the angular-seed repository and install the dependencies:
11
+
To get you started you can simply clone the angularjs-typescript-webpack repository and install the dependencies:
16
12
17
13
### Prerequisites
18
14
19
-
You need git to clone the angular-seed repository. You can get git from
15
+
You need git to clone the angularjs-typescript-webpack repository. You can get git from
20
16
[http://git-scm.com/](http://git-scm.com/).
21
17
22
18
We also use a number of node.js tools to initialize and test angular-seed. You must have node.js and
23
19
its package manager (npm) installed. You can get them from [http://nodejs.org/](http://nodejs.org/).
24
20
25
-
### Clone angular-seed
26
-
27
-
Clone the angular-seed repository using [git][git]:
The `depth=1` tells git to only pull down one commit worth of historical data.
23
+
Clone the angularjs-typescript-webpack repository using git:
41
24
42
25
### Install Dependencies
43
26
44
-
We have two kinds of dependencies in this project: tools and angular framework code. The tools help
45
-
us manage and test the application.
46
-
47
-
* We get the tools we depend upon via `npm`, the [node package manager][npm].
48
-
* We get the angular code via `bower`, a [client-side code package manager][bower].
49
-
50
-
We have preconfigured `npm` to automatically run `bower` so we can simply do:
27
+
We have two kinds of dependencies in this project: development tools and application specific packages. They are both managed with npm in package.json as devDependencies and dependecies respectively.
51
28
52
29
```
53
30
npm install
54
31
```
55
32
56
-
Behind the scenes this will also call `bower install`. You should find that you have two new
57
-
folders in your project.
58
-
59
-
*`node_modules` - contains the npm packages for the tools we need
60
-
*`app/bower_components` - contains the angular framework files
61
-
62
-
*Note that the `bower_components` folder would normally be installed in the root folder but
63
-
angular-seed changes this location through the `.bowerrc` file. Putting it in the app folder makes
64
-
it easier to serve the files by a webserver.*
65
-
66
33
### Run the Application
67
34
68
35
We have preconfigured the project with a simple development web server. The simplest way to start
@@ -72,177 +39,31 @@ this server is:
72
39
npm start
73
40
```
74
41
75
-
Now browse to the app at `http://localhost:8000/app/index.html`.
42
+
Now browse to the app at `http://localhost:8080/`.
76
43
77
44
78
45
79
46
## Directory Layout
80
47
81
48
```
82
-
app/ --> all of the source files for the application
49
+
src/ --> all of the source files for the application
83
50
app.css --> default stylesheet
84
51
components/ --> all app specific modules
85
-
version/ --> version related components
86
-
version.js --> version module declaration and basic "version" value service
87
-
version_test.js --> "version" value service tests
88
-
version-directive.js --> custom directive that returns the current app version
89
-
version-directive_test.js --> version directive tests
index.html --> app layout file (the main html template file of the app)
102
-
index-async.html --> just like index.html, but loads js files asynchronously
103
-
karma.conf.js --> config file for running unit tests with Karma
104
-
e2e-tests/ --> end-to-end tests
105
-
protractor-conf.js --> Protractor config file
106
-
scenarios.js --> end-to-end scenarios to be run by Protractor
107
-
```
108
-
109
-
## Testing
110
-
111
-
There are two kinds of tests in the angular-seed application: Unit tests and End to End tests.
112
-
113
-
### Running Unit Tests
114
-
115
-
The angular-seed app comes preconfigured with unit tests. These are written in
116
-
[Jasmine][jasmine], which we run with the [Karma Test Runner][karma]. We provide a Karma
117
-
configuration file to run them.
118
-
119
-
* the configuration is found at `karma.conf.js`
120
-
* the unit tests are found next to the code they are testing and are named as `..._test.js`.
121
-
122
-
The easiest way to run the unit tests is to use the supplied npm script:
123
-
124
-
```
125
-
npm test
126
-
```
127
-
128
-
This script will start the Karma test runner to execute the unit tests. Moreover, Karma will sit and
129
-
watch the source and test files for changes and then re-run the tests whenever any of them change.
130
-
This is the recommended strategy; if your unit tests are being run every time you save a file then
131
-
you receive instant feedback on any changes that break the expected code functionality.
132
-
133
-
You can also ask Karma to do a single run of the tests and then exit. This is useful if you want to
134
-
check that a particular version of the code is operating as expected. The project contains a
135
-
predefined script to do this:
136
-
137
-
```
138
-
npm run test-single-run
139
-
```
140
-
141
-
142
-
### End to end testing
143
-
144
-
The angular-seed app comes with end-to-end tests, again written in [Jasmine][jasmine]. These tests
145
-
are run with the [Protractor][protractor] End-to-End test runner. It uses native events and has
146
-
special features for Angular applications.
147
-
148
-
* the configuration is found at `e2e-tests/protractor-conf.js`
149
-
* the end-to-end tests are found in `e2e-tests/scenarios.js`
150
-
151
-
Protractor simulates interaction with our web app and verifies that the application responds
152
-
correctly. Therefore, our web server needs to be serving up the application, so that Protractor
153
-
can interact with it.
154
-
155
-
```
156
-
npm start
157
-
```
158
-
159
-
In addition, since Protractor is built upon WebDriver we need to install this. The angular-seed
160
-
project comes with a predefined script to do this:
161
-
162
-
```
163
-
npm run update-webdriver
164
-
```
165
-
166
-
This will download and install the latest version of the stand-alone WebDriver tool.
167
-
168
-
Once you have ensured that the development web server hosting our application is up and running
169
-
and WebDriver is updated, you can run the end-to-end tests using the supplied npm script:
170
-
171
56
```
172
-
npm run protractor
173
-
```
174
-
175
-
This script will execute the end-to-end tests against the application being hosted on the
176
-
development server.
177
-
178
-
179
-
## Updating Angular
180
-
181
-
Previously we recommended that you merge in changes to angular-seed into your own fork of the project.
182
-
Now that the angular framework library code and tools are acquired through package managers (npm and
183
-
bower) you can use these tools instead to update the dependencies.
184
-
185
-
You can update the tool dependencies by running:
186
-
187
-
```
188
-
npm update
189
-
```
190
-
191
-
This will find the latest versions that match the version ranges specified in the `package.json` file.
192
-
193
-
You can update the Angular dependencies by running:
194
-
195
-
```
196
-
bower update
197
-
```
198
-
199
-
This will find the latest versions that match the version ranges specified in the `bower.json` file.
200
-
201
-
202
-
## Loading Angular Asynchronously
203
-
204
-
The angular-seed project supports loading the framework and application scripts asynchronously. The
205
-
special `index-async.html` is designed to support this style of loading. For it to work you must
206
-
inject a piece of Angular JavaScript into the HTML page. The project has a predefined script to help
207
-
do this.
208
-
209
-
```
210
-
npm run update-index-async
211
-
```
212
-
213
-
This will copy the contents of the `angular-loader.js` library file into the `index-async.html` page.
214
-
You can run this every time you update the version of Angular that you are using.
215
-
216
-
217
-
## Serving the Application Files
218
-
219
-
While angular is client-side-only technology and it's possible to create angular webapps that
220
-
don't require a backend server at all, we recommend serving the project files using a local
221
-
webserver during development to avoid issues with security restrictions (sandbox) in browsers. The
222
-
sandbox implementation varies between browsers, but quite often prevents things like cookies, xhr,
223
-
etc to function properly when an html page is opened via `file://` scheme instead of `http://`.
224
-
225
57
226
58
### Running the App during Development
227
59
228
-
The angular-seed project comes preconfigured with a local development webserver. It is a node.js
229
-
tool called [http-server][http-server]. You can start this webserver with `npm start` but you may choose to
230
-
install the tool globally:
60
+
Typescript development is dependant on typings project, that need to be installed globally prior to development.
231
61
232
62
```
233
-
sudo npm install -g http-server
63
+
sudo npm install -g typings
234
64
```
235
65
236
-
Then you can start your own development web server to serve static files from a folder by
237
-
running:
238
-
239
-
```
240
-
http-server -a localhost -p 8000
241
-
```
242
-
243
-
Alternatively, you can choose to configure your own webserver, such as apache or nginx. Just
244
-
configure your server to serve the files under the `app/` directory.
245
-
66
+
The angularjs-typescript-webpack project comes preconfigured with a local development webserver. It is a webpack-dev-server, that supports hot reload. You can start this webserver with `npm start`.
246
67
247
68
### Running the App in Production
248
69
@@ -257,41 +78,3 @@ If your Angular app is talking to the backend server via xhr or other means, you
257
78
out what is the best way to host the static files to comply with the same origin policy if
258
79
applicable. Usually this is done by hosting the files by the backend server or through
259
80
reverse-proxying the backend server(s) and webserver(s).
260
-
261
-
262
-
## Continuous Integration
263
-
264
-
### Travis CI
265
-
266
-
[Travis CI][travis] is a continuous integration service, which can monitor GitHub for new commits
267
-
to your repository and execute scripts such as building the app or running tests. The angular-seed
268
-
project contains a Travis configuration file, `.travis.yml`, which will cause Travis to run your
269
-
tests when you push to GitHub.
270
-
271
-
You will need to enable the integration between Travis and GitHub. See the Travis website for more
0 commit comments