Skip to content

Commit a011a8f

Browse files
author
Vlad Sternbach
committed
- changed a little the folder structure
- fixed build script - added dist folder with latest build
1 parent 9512039 commit a011a8f

File tree

6 files changed

+23
-31
lines changed

6 files changed

+23
-31
lines changed

README.md

+3-14
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ Now browse to the app at `http://localhost:8080/`.
4747

4848
```
4949
src/ --> all of the source files for the application
50-
app.css --> default stylesheet
5150
components/ --> all app specific modules
5251
services/ --> all app common services
5352
assets/ --> all of the app static assets
@@ -63,18 +62,8 @@ Typescript development is dependant on typings project, that need to be installe
6362
sudo npm install -g typings
6463
```
6564

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`.
65+
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`.
6766

68-
### Running the App in Production
67+
### Building and running the App in Production
6968

70-
This really depends on how complex your app is and the overall infrastructure of your system, but
71-
the general rule is that all you need in production are all the files under the `app/` directory.
72-
Everything else should be omitted.
73-
74-
Angular apps are really just a bunch of static html, css and js files that just need to be hosted
75-
somewhere they can be accessed by browsers.
76-
77-
If your Angular app is talking to the backend server via xhr or other means, you need to figure
78-
out what is the best way to host the static files to comply with the same origin policy if
79-
applicable. Usually this is done by hosting the files by the backend server or through
80-
reverse-proxying the backend server(s) and webserver(s).
69+
To build the application for production just run `npm bundle`, it creates dist directory that have the production optimized build.

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
2-
"name": "angular-seed",
2+
"name": "angularjs-typescript-webpack",
33
"private": true,
44
"version": "0.0.0",
5-
"description": "A starter project for AngularJS",
6-
"repository": "https://github.com/angular/angular-seed",
5+
"description": "Angularjs-typescript-webpack starter project",
6+
"repository": "https://github.com/vsternbach/angularjs-typescript-webpack",
77
"license": "MIT",
88
"devDependencies": {
99
"awesome-typescript-loader": "^0.17.0-rc.4",
10+
"copyfiles": "^0.2.1",
1011
"css-loader": "^0.23.1",
1112
"node-sass": "^3.4.2",
13+
"rimraf": "^2.5.2",
1214
"sass-loader": "^3.2.0",
1315
"style-loader": "^0.13.1",
1416
"ts-loader": "^0.8.1",
@@ -26,6 +28,6 @@
2628
"scripts": {
2729
"prestart": "npm install",
2830
"start": "webpack-dev-server --hot",
29-
"bundle": "cp src/index.html dist/ & webpack -p ./dist/bundle.js"
31+
"bundle": "rimraf dist & copyfiles -f src/index.html dist/ & copyfiles -f src/assets/* dist/assets & webpack -p ./dist/bundle.js"
3032
}
3133
}

src/assets/edit.svg

-1
This file was deleted.

src/mock.json src/assets/mock.json

File renamed without changes.

src/main.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,13 @@ import components from './components/components.module';
1111
import './components/comment/comment.component';
1212
import './components/comment-list/comments.component';
1313

14-
// configure the main module
15-
angular.module('app', [
16-
'ngTagsInput',
17-
'ngSanitize',
18-
'ui.router',
19-
services.name,
20-
components.name
21-
])
22-
.config(function($urlRouterProvider, $stateProvider, tagsInputConfigProvider) {
14+
function appConfig ($urlRouterProvider, $stateProvider, tagsInputConfigProvider) {
2315
$urlRouterProvider.otherwise('/');
2416
$stateProvider
2517
.state('index', {
2618
url: '/',
2719
template: '<comments></comments>'
2820
});
29-
3021
tagsInputConfigProvider
3122
.setDefaults('tagsInput', {
3223
placeholder: 'Search tags',
@@ -35,7 +26,18 @@ angular.module('app', [
3526
.setDefaults('autoComplete', {
3627
minLength: 1
3728
})
38-
});
29+
}
30+
appConfig.$inject = ['$urlRouterProvider', '$stateProvider', 'tagsInputConfigProvider'];
31+
32+
// configure the main module
33+
angular.module('app', [
34+
'ngTagsInput',
35+
'ngSanitize',
36+
'ui.router',
37+
services.name,
38+
components.name
39+
])
40+
.config(appConfig);
3941

4042
// bootstrap angular
4143
angular.element(document).ready(() => {

src/services/comments.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class Comments {
1010
}
1111

1212
getComments() {
13-
return this.$http.get('mock.json').then((response: {data: IComment[]}) => {
13+
return this.$http.get('assets/mock.json').then((response: {data: IComment[]}) => {
1414
return response.data;
1515
});
1616
};

0 commit comments

Comments
 (0)