Skip to content

Commit 7cc00a7

Browse files
committed
initial commit
0 parents  commit 7cc00a7

19 files changed

+577
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.eslintrc.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es6": true,
6+
"node": true
7+
},
8+
"parser": "typescript-eslint-parser",
9+
"parserOptions": {
10+
"ecmaFeatures": {
11+
"experimentalObjectRestSpread": true
12+
},
13+
"sourceType": "module"
14+
},
15+
"extends": [
16+
// "airbnb",
17+
"eslint:recommended",
18+
],
19+
"plugins": [
20+
"typescript",
21+
],
22+
"rules": {
23+
"no-undef": 0,
24+
// "no-unused-vars": 0,
25+
}
26+
};

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
~*
2+
/node_modules/
3+
/build/
4+
/.testresults/

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
save-exact=true
2+
loglevel=silent

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# angular-webpack-seed
2+
3+
TODO
4+
---
5+
* test isolated modules
6+
* dev task: lint, ts check, webpack
7+
* more eslint plugins
8+
* karma coverage
9+
* disable hot reload in coverage
10+
11+
DEBUG
12+
---
13+
```
14+
inspect node_modules/webpack-dev-server/bin/webpack-dev-server
15+
```

karma.conf.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/// <reference path="node_modules/@types/node/index.d.ts" />
2+
/// <reference path="node_modules/typescript/lib/lib.es2017.d.ts" />
3+
import * as _ from 'lodash';
4+
import { Config } from 'karma';
5+
import { Configuration } from 'webpack';
6+
import webpackConfig = require('./webpack.config');
7+
8+
export = (config: any) => {
9+
10+
const karma: Config = config;
11+
12+
karma.set({
13+
files: [
14+
{ pattern: 'build/vendors.js', watched: false },
15+
{ pattern: 'src/specs.ts' },
16+
],
17+
preprocessors: {
18+
'**/specs.ts': ['webpack', 'sourcemap']
19+
},
20+
browsers: ['Nightmare'],
21+
frameworks: [
22+
'jasmine',
23+
],
24+
reporters: ['progress'],
25+
});
26+
27+
config.set({
28+
mime: {
29+
'text/x-typescript': ['ts', 'tsx'],
30+
},
31+
nightmareOptions: {
32+
width: 800,
33+
height: 600,
34+
show: false,
35+
},
36+
webpack: webpackConfig({ hmr: false, test: true }),
37+
webpackMiddleware: {
38+
stats: 'minimal'
39+
}
40+
});
41+
42+
if (process.argv.indexOf('--coverage') !== -1) {
43+
config.set({
44+
preprocessors: {
45+
'**/specs.ts': ['coverage', 'webpack', 'sourcemap']
46+
},
47+
reporters: ['mocha', 'coverage', 'remap-coverage'],
48+
coverageReporter: {
49+
type: 'in-memory'
50+
},
51+
remapCoverageReporter: {
52+
'text-summary': null,
53+
json: '.testresults/coverage.json',
54+
html: '.testresults/coverage'
55+
},
56+
webpack: webpackConfig({ hmr: false, test: true, coverage: true }),
57+
});
58+
}
59+
};

package.json

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"name": "angular-webpack-seed",
3+
"version": "0.0.0",
4+
"private": true,
5+
"description": "",
6+
"scripts": {
7+
"gulp": "ts-node -F node_modules/gulp/bin/gulp",
8+
"start": "npm run server",
9+
"eslint": "eslint src/**/*.ts",
10+
"clean": "rm -rf build",
11+
"compile": "tsc",
12+
"compile:w": "tsc --watch",
13+
"tschk": "tsc --noEmit --noUnusedLocals",
14+
"test": "npm run build && npm run eslint && npm run tschk -q && npm run coverage",
15+
"t": "npm run karma -- --single-run",
16+
"tests:w": "npm run karma",
17+
"server": "webpack-dev-server --hot --inline --progress --colors",
18+
"server:dashboard": "npm run server -- --env.dashboard",
19+
"build": "webpack --progress --colors",
20+
"build:prod": "npm run build -- -p",
21+
"dashboard": "webpack-dashboard -- npm run server:dashboard",
22+
"up": "updtr --test-stdout --save-exact -R simple --test \"npm run test\"",
23+
"build:vendors": "npm run build -- --env.vendors",
24+
"postinstall": "npm run build:dll",
25+
"yi": "yarn install --no-lockfile",
26+
"karma": "karma start",
27+
"coverage": "npm run karma -- --single-run --coverage",
28+
"coverage:debug": "npm run karma coverage -- --log-level debug"
29+
},
30+
"license": "MIT",
31+
"devDependencies": {
32+
"@types/jasmine": "2.5.47",
33+
"@types/karma": "0.13.34",
34+
"@types/lodash": "4.14.61",
35+
"@types/node": "7.0.12",
36+
"@types/webpack": "2.2.14",
37+
"@types/webpack-env": "1.13.0",
38+
"autoprefixer": "6.7.7",
39+
"awesome-typescript-loader": "3.1.2",
40+
"css-loader": "0.28.0",
41+
"eslint": "3.18.0",
42+
"eslint-plugin-typescript": "0.1.0",
43+
"extract-text-webpack-plugin": "2.1.0",
44+
"fmt-obj": "1.3.0",
45+
"html-loader": "0.4.5",
46+
"html-webpack-plugin": "2.28.0",
47+
"istanbul-instrumenter-loader": "2.0.0",
48+
"jasmine-core": "2.5.2",
49+
"karma": "1.5.0",
50+
"karma-coverage": "1.1.1",
51+
"karma-jasmine": "1.1.0",
52+
"karma-mocha-reporter": "2.2.3",
53+
"karma-nightmare": "0.4.5",
54+
"karma-remap-coverage": "0.1.4",
55+
"karma-sourcemap-loader": "0.3.7",
56+
"karma-webpack": "2.0.3",
57+
"lodash": "4.17.4",
58+
"node-sass": "4.5.2",
59+
"postcss": "5.2.16",
60+
"postcss-import": "9.1.0",
61+
"postcss-loader": "1.3.3",
62+
"postcss-url": "5.1.2",
63+
"raw-loader": "0.5.1",
64+
"sass-loader": "6.0.3",
65+
"style-loader": "0.16.1",
66+
"ts-node": "3.0.2",
67+
"tslib": "1.6.0",
68+
"typescript": "2.2.2",
69+
"typescript-eslint-parser": "2.0.0",
70+
"url-loader": "0.5.8",
71+
"webpack": "2.3.2",
72+
"webpack-dashboard": "0.3.0",
73+
"webpack-dev-server": "2.4.2",
74+
"webpack-hot-middleware": "2.17.1"
75+
},
76+
"dependencies": {
77+
"@angular/common": "2.4.9",
78+
"@angular/compiler": "2.4.9",
79+
"@angular/core": "2.4.9",
80+
"@angular/forms": "2.4.9",
81+
"@angular/http": "2.4.9",
82+
"@angular/platform-browser": "2.4.9",
83+
"@angular/platform-browser-dynamic": "2.4.9",
84+
"@angular/router": "3.4.9",
85+
"core-js": "2.4.1",
86+
"rxjs": "5.2.0",
87+
"zone.js": "0.8.4"
88+
}
89+
}

src/app/app.component.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<input [(ngModel)]="name">
2+
3+
<p>Hello {{name}}</p>
4+
5+
<div>
6+
<a [routerLink]="['/']">Home</a>
7+
<a [routerLink]="['about']">About</a> (loading lazy)
8+
</div>
9+
10+
<router-outlet></router-outlet>

src/app/app.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$color: #555;
2+
input {
3+
border-radius: 3px;
4+
border: 1px solid $color;
5+
}

src/app/app.component.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { AppComponent } from './app.component';
2+
3+
describe('App component', () => {
4+
5+
it('smoke', () => {
6+
expect(AppComponent).toBeDefined();
7+
});
8+
9+
it('instance', () => {
10+
let appComponent = new AppComponent();
11+
expect(appComponent.name).toBe('Angular');
12+
});
13+
});

src/app/app.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app',
5+
template: require('./app.component.html'),
6+
styles: [require('./app.component.scss')],
7+
})
8+
export class AppComponent {
9+
name = 'Angular';
10+
}

src/app/app.module.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { NgModule, ErrorHandler } from '@angular/core';
2+
import { BrowserModule } from '@angular/platform-browser';
3+
import { AppComponent } from './app.component';
4+
import { Routes, RouterModule } from '@angular/router';
5+
import { HashLocationStrategy, LocationStrategy, APP_BASE_HREF, CommonModule } from '@angular/common';
6+
import { FormsModule } from '@angular/forms';
7+
8+
const routes: Routes = [
9+
];
10+
11+
class AppErrorHandler extends ErrorHandler {
12+
13+
constructor() {
14+
super(true);
15+
}
16+
17+
handleError(err: any) {
18+
throw err;
19+
}
20+
}
21+
22+
@NgModule({
23+
imports: [
24+
CommonModule,
25+
BrowserModule,
26+
FormsModule,
27+
RouterModule.forRoot(routes),
28+
],
29+
declarations: [
30+
AppComponent,
31+
],
32+
bootstrap: [AppComponent],
33+
providers: [
34+
{ provide: APP_BASE_HREF, useValue: '/' },
35+
{ provide: LocationStrategy, useClass: HashLocationStrategy },
36+
{ provide: ErrorHandler, useClass: AppErrorHandler },
37+
]
38+
})
39+
export class AppModule { }

src/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<title>Angular App</title>
9+
</head>
10+
<body>
11+
<app>Loading...</app>
12+
<script src="vendors.js"></script>
13+
</body>
14+
</html>

src/main.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import 'core-js/es6';
2+
import 'core-js/es7';
3+
import 'zone.js/dist/zone';
4+
import './style.scss';
5+
6+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
7+
import { enableProdMode } from '@angular/core';
8+
import { AppModule } from './app/app.module';
9+
10+
if (process.env.NODE_ENV === 'production') {
11+
enableProdMode();
12+
}
13+
14+
platformBrowserDynamic().bootstrapModule(AppModule);

src/spec.module.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// <reference path="typings.d.ts" />
2+
require('core-js/es6');
3+
require('core-js/es7');
4+
require('zone.js/dist/zone');
5+
require('zone.js/dist/long-stack-trace-zone.js');
6+
require('zone.js/dist/proxy.js');
7+
require('zone.js/dist/sync-test.js');
8+
require('zone.js/dist/jasmine-patch.js');
9+
require('zone.js/dist/async-test.js');
10+
require('zone.js/dist/fake-async-test.js');
11+
require('rxjs/Rx');
12+
13+
import { TestBed } from '@angular/core/testing';
14+
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
15+
16+
TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
17+
18+
const requireContext = require.context('./', true, /\.spec\.ts$/);
19+
requireContext.keys().forEach(id => {
20+
requireContext(id);
21+
});

src/style.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.grid {
2+
display: grid;
3+
}
4+
5+
body {
6+
font-family: 'Segoe UI'
7+
}

src/typings.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference path="../node_modules/@types/webpack-env/index.d.ts" />
2+
/// <reference path="../node_modules/typescript/lib/lib.es2017.d.ts" />
3+
/// <reference path="../node_modules/typescript/lib/lib.dom.d.ts" />

tsconfig.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"importHelpers": true,
6+
"moduleResolution": "node",
7+
"emitDecoratorMetadata": true,
8+
"experimentalDecorators": true,
9+
"sourceMap": true,
10+
"declaration": false,
11+
"pretty": true,
12+
"outDir": "build",
13+
"lib": [
14+
"es7",
15+
"dom"
16+
]
17+
},
18+
"include": [
19+
"src/main.ts"
20+
]
21+
}

0 commit comments

Comments
 (0)