Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit 41be4e2

Browse files
author
Plum-Crazy
committed
Upgrading various packages, updating readme, switching repo url, add code coverage and better karma test support
1 parent 9c96c6f commit 41be4e2

22 files changed

+295
-312
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea/
22
node_modules/
3-
dist/
3+
dist/
4+
coverage/

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
A basic Angular 4 seed project utilizing the following technologies:
44

5-
* Angular 4.0.2
6-
* TypeScript 2.2
7-
* Karma/Jasmine (unit testing)
8-
* Codelyzer & TSLint (code linting)
9-
* PugJS (template engine)
10-
* SASS (css superset)
11-
* Webpack 2+ (build tools)
5+
* Angular 4.3.5
6+
* TypeScript 2.5
7+
* Karma/Jasmine
8+
* Codelyzer & TSLint
9+
* SASS/SCSS
10+
* Webpack 3
1211

1312
### Commands
1413

config/build/webpack.common.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
var webpack = require('webpack');
2+
var HtmlWebpackPlugin = require('html-webpack-plugin');
3+
var helpers = require('../helpers');
4+
5+
module.exports = {
6+
entry: {
7+
'polyfills': './src/polyfills.ts',
8+
'vendor': './src/vendor.ts',
9+
'app': './src/main.ts'
10+
},
11+
12+
resolve: {
13+
extensions: [
14+
'.js', '.ts'
15+
]
16+
},
17+
18+
module: {
19+
rules: [
20+
{
21+
test: /\.ts$/,
22+
use: [ 'awesome-typescript-loader?configFileName=config/tsconfig.json', 'angular2-template-loader' ]
23+
},
24+
{
25+
test: /\.html$/,
26+
use: 'html-loader'
27+
},
28+
{
29+
test: /\.pug$/,
30+
use: [ 'raw-loader', 'pug-html-loader' ]
31+
},
32+
{
33+
test: /\.scss$/,
34+
exclude: /node_modules/,
35+
use: [ 'raw-loader', 'css-loader', 'sass-loader' ]
36+
},
37+
{
38+
test: /\.(png|jpe?g|gif|svg|woff|woff2|otf|ttf|eot|ico)$/,
39+
use: 'file-loader?name=assets/[name].[hash].[ext]'
40+
},
41+
{
42+
test: /\.css$/,
43+
exclude: helpers.root('src', 'app'),
44+
use: [ 'raw-loader', 'css-loader' ]
45+
}
46+
]
47+
},
48+
49+
plugins: [
50+
new webpack.optimize.CommonsChunkPlugin({
51+
name: [ 'app', 'vendor', 'polyfills' ]
52+
}),
53+
54+
new HtmlWebpackPlugin({
55+
template: 'src/index.html'
56+
}),
57+
58+
new webpack.ContextReplacementPlugin(
59+
/angular(\\|\/)core(\\|\/)@angular/,
60+
helpers.root('src'), // location of your src
61+
{}
62+
)
63+
]
64+
};

config/build/webpack.dev.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var webpackMerge = require('webpack-merge');
2+
var commonConfig = require('./webpack.common.js');
3+
var helpers = require('../helpers');
4+
5+
module.exports = webpackMerge(commonConfig, {
6+
devtool: 'cheap-module-eval-source-map',
7+
8+
output: {
9+
path: helpers.root('dist'),
10+
publicPath: 'http://localhost:3000/',
11+
filename: '[name].js',
12+
chunkFilename: '[id].chunk.js'
13+
},
14+
15+
devServer: {
16+
historyApiFallback: true,
17+
stats: 'minimal'/*,
18+
TODO setup when REST service ready
19+
proxy: {
20+
'/api/**': {
21+
target: 'http://localhost:8080/your-rest-service',
22+
secure: false,
23+
changeOrigin: true
24+
}
25+
}*/
26+
}
27+
});

config/webpack.prod.js renamed to config/build/webpack.prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var webpack = require("webpack");
22
var webpackMerge = require("webpack-merge");
33
var ExtractTextPlugin = require("extract-text-webpack-plugin");
44
var commonConfig = require("./webpack.common.js");
5-
var helpers = require("./helpers");
5+
var helpers = require("../helpers");
66

77
const ENV = process.env.NODE_ENV = process.env.ENV = "production";
88

config/karma-test-shim.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

config/karma.conf.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

config/test/karma-test-shim.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Error.stackTraceLimit = Infinity;
2+
3+
require("core-js/es6");
4+
require("reflect-metadata");
5+
6+
require("zone.js/dist/zone");
7+
require("zone.js/dist/long-stack-trace-zone");
8+
require("zone.js/dist/proxy");
9+
require("zone.js/dist/sync-test");
10+
require("zone.js/dist/jasmine-patch");
11+
require("zone.js/dist/async-test");
12+
require("zone.js/dist/fake-async-test");
13+
14+
const testing = require("@angular/core/testing");
15+
const browser = require("@angular/platform-browser-dynamic/testing");
16+
17+
// Prevent Karma from running prematurely.
18+
__karma__.loaded = function () {};
19+
20+
// First, initialize the Angular testing environment.
21+
testing.TestBed.initTestEnvironment(
22+
browser.BrowserDynamicTestingModule,
23+
browser.platformBrowserDynamicTesting()
24+
);
25+
// Then we find all the tests.
26+
const context = require.context('../../src', true, /\.spec\.ts$/);
27+
// And load the modules.
28+
context.keys().map(context);
29+
// Finally, start Karma to run the tests.
30+
__karma__.start();

config/test/karma.conf.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
var webpackConfig = require('./webpack.test');
2+
3+
module.exports = function(config) {
4+
config.set({
5+
basePath: '',
6+
files: [
7+
{
8+
pattern: './karma-test-shim.js',
9+
watched: false
10+
}
11+
],
12+
preprocessors: {
13+
'./karma-test-shim.js': [
14+
'webpack', 'sourcemap'
15+
]
16+
},
17+
frameworks: [ 'jasmine' ],
18+
plugins: [
19+
require('karma-jasmine'),
20+
require('karma-chrome-launcher'),
21+
require('karma-jasmine-html-reporter'),
22+
require('karma-coverage-istanbul-reporter'),
23+
require('karma-webpack'),
24+
require('karma-sourcemap-loader')
25+
],
26+
client:{
27+
clearContext: false
28+
},
29+
webpack: webpackConfig,
30+
coverageIstanbulReporter: {
31+
reports: [ 'html', 'lcovonly' ],
32+
fixWebpackSourcePaths: true,
33+
remapOptions: {
34+
exclude: /\*.spec.ts/
35+
}
36+
},
37+
reporters: [ 'progress', /*'kjhtml', */'coverage-istanbul' ],
38+
port: 9876,
39+
colors: true,
40+
logLevel: config.LOG_INFO,
41+
autoWatch: true,
42+
browsers: [ 'Chrome' ],
43+
singleRun: true
44+
});
45+
};

config/test/webpack.test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
var webpack = require('webpack');
2+
var helpers = require('../helpers');
3+
4+
module.exports = {
5+
devtool: 'inline-source-map',
6+
7+
resolve: {
8+
extensions: [ '.ts', '.js' ]
9+
},
10+
11+
module: {
12+
rules: [
13+
{
14+
test: /\.ts$/,
15+
use: [ 'istanbul-instrumenter-loader', 'awesome-typescript-loader?configFileName=config/tsconfig.json', 'angular2-template-loader' ],
16+
exclude: /\.spec\.ts$/
17+
},
18+
{
19+
test: /\.html$/,
20+
use: 'html-loader'
21+
},
22+
{
23+
test: /\.pug$/,
24+
use: [ 'raw-loader', 'pug-html-loader' ]
25+
},
26+
{
27+
test: /\.scss$/,
28+
exclude: /node_modules/,
29+
use: [ 'raw-loader', 'sass-loader' ]
30+
},
31+
{
32+
test: /\.css$/,
33+
include: helpers.root('src', 'app'),
34+
use: 'raw-loader'
35+
}
36+
]
37+
},
38+
39+
plugins: [
40+
new webpack.ContextReplacementPlugin(
41+
/angular(\\|\/)core(\\|\/)@angular/,
42+
helpers.root('src'),
43+
{}
44+
)
45+
]
46+
};

config/tsconfig.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
"sourceMap": true,
77
"emitDecoratorMetadata": true,
88
"experimentalDecorators": true,
9-
"lib": [ "es2015", "dom" ],
109
"noImplicitAny": true,
1110
"suppressImplicitAnyIndexErrors": true,
1211
"typeRoots": [
1312
"../node_modules/@types"
13+
],
14+
"lib": [
15+
"es2017",
16+
"dom"
1417
]
1518
},
16-
"exclude": [
17-
"../node_modules"
18-
],
1919
"include": [
2020
"../**/*"
2121
]

config/tslint.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
true,
88
"attribute",
99
[
10-
"plum"
10+
"tyn"
1111
],
1212
"camelCase"
1313
],
1414
"component-selector": [
1515
true,
1616
"element",
1717
[
18-
"plum"
18+
"tyn"
1919
],
2020
"kebab-case"
2121
],

0 commit comments

Comments
 (0)