Skip to content

Commit b000bea

Browse files
author
Mario Christopher
committed
Initial Commit
1 parent b70a642 commit b000bea

15 files changed

+275
-0
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# yum-recipes !
2+
**yum-recipes** is a Single Page Application (SPA) built using [Angular4](https://angular.io/). It is configured using [Webpack](https://webpack.github.io/docs/).
3+
* Development on this repository is still in progress. Please check back here in a few days.
4+
5+
## License
6+
7+
Shared under MIT License.

config/helpers.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var path = require('path');
2+
3+
var _root = path.resolve(__dirname, '..');
4+
5+
function root(args) {
6+
args = Array.prototype.slice.call(arguments, 0);
7+
return path.join.apply(path, [_root].concat(args));
8+
}
9+
10+
exports.root = root;

config/webpack.common.js

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
var webpack = require('webpack');
2+
var HtmlWebpackPlugin = require('html-webpack-plugin');
3+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
4+
var helpers = require('./helpers');
5+
6+
module.exports = {
7+
entry: {
8+
'polyfills': './src/client/polyfills.ts',
9+
'vendor': './src/client/vendor.ts',
10+
'app': './src/client/main.ts'
11+
},
12+
13+
resolve: {
14+
extensions: ['.ts', '.js']
15+
},
16+
17+
module: {
18+
rules: [
19+
{
20+
test: /\.ts$/,
21+
loaders: [
22+
{
23+
loader: 'awesome-typescript-loader',
24+
options: { configFileName: helpers.root('src', 'client', 'tsconfig.json') }
25+
}, 'angular2-template-loader'
26+
]
27+
},
28+
{
29+
test: /\.html$/,
30+
loader: 'html-loader'
31+
},
32+
{
33+
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
34+
loader: 'file-loader?name=assets/[name].[hash].[ext]'
35+
},
36+
{
37+
test: /\.css$/,
38+
use: ExtractTextPlugin.extract({
39+
fallback: 'style-loader',
40+
use: 'css-loader'
41+
})
42+
}
43+
]
44+
},
45+
46+
plugins: [
47+
// Workaround for angular/angular#11580
48+
new webpack.ContextReplacementPlugin(
49+
// The (\\|\/) piece accounts for path separators in *nix and Windows
50+
/angular(\\|\/)core(\\|\/)@angular/,
51+
helpers.root('./src/client'), // location of your src
52+
{} // a map of your routes
53+
),
54+
55+
new webpack.optimize.CommonsChunkPlugin({
56+
name: ['app', 'vendor', 'polyfills']
57+
}),
58+
59+
new HtmlWebpackPlugin({
60+
template: 'src/client/index.html'
61+
})
62+
]
63+
};

config/webpack.dev.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var webpackMerge = require('webpack-merge');
2+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
3+
var commonConfig = require('./webpack.common.js');
4+
var helpers = require('./helpers');
5+
6+
module.exports = webpackMerge(commonConfig, {
7+
devtool: 'cheap-module-eval-source-map',
8+
9+
output: {
10+
path: helpers.root('dist'),
11+
publicPath: '/',
12+
filename: '[name].js',
13+
chunkFilename: '[id].chunk.js'
14+
},
15+
16+
plugins: [
17+
new ExtractTextPlugin('[name].css')
18+
],
19+
20+
devServer: {
21+
port: 8080,
22+
historyApiFallback: true,
23+
stats: 'minimal'
24+
}
25+
});

config/webpack.prod.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
var webpack = require('webpack');
2+
var webpackMerge = require('webpack-merge');
3+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
4+
var commonConfig = require('./webpack.common.js');
5+
var helpers = require('./helpers');
6+
7+
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
8+
9+
module.exports = webpackMerge(commonConfig, {
10+
devtool: 'source-map',
11+
12+
output: {
13+
path: helpers.root('dist'),
14+
publicPath: '/',
15+
filename: '[name].[hash].js',
16+
chunkFilename: '[id].[hash].chunk.js'
17+
},
18+
19+
plugins: [
20+
new webpack.NoEmitOnErrorsPlugin(),
21+
new webpack.optimize.UglifyJsPlugin({ // https://github.com/angular/angular/issues/10618
22+
mangle: {
23+
keep_fnames: true
24+
}
25+
}),
26+
new ExtractTextPlugin('[name].[hash].css'),
27+
new webpack.DefinePlugin({
28+
'process.env': {
29+
'NODE_ENV': JSON.stringify(ENV),
30+
'ENV': JSON.stringify(ENV)
31+
}
32+
}),
33+
new webpack.LoaderOptionsPlugin({
34+
htmlLoader: {
35+
minimize: false // workaround for ng2
36+
}
37+
})
38+
]
39+
});

package.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "hello-world-angular",
3+
"version": "1.0.0",
4+
"description": "This is a simple starter application built using Angular4. It is configured using Webpack",
5+
"scripts": {
6+
"client": "webpack-dev-server --progress",
7+
"buildui": "rimraf dist && webpack --progress"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"@angular/common": "^4.3.6",
14+
"@angular/compiler": "^4.3.6",
15+
"@angular/core": "^4.3.6",
16+
"@angular/platform-browser": "^4.3.6",
17+
"@angular/platform-browser-dynamic": "^4.3.6",
18+
"core-js": "^2.5.0",
19+
"rxjs": "^5.4.3",
20+
"zone.js": "^0.8.17"
21+
},
22+
"devDependencies": {
23+
"@types/node": "^8.0.25",
24+
"angular2-template-loader": "^0.6.2",
25+
"awesome-typescript-loader": "^3.2.3",
26+
"css-loader": "^0.28.5",
27+
"extract-text-webpack-plugin": "^3.0.0",
28+
"file-loader": "^0.11.2",
29+
"html-loader": "^0.5.1",
30+
"html-webpack-plugin": "^2.30.1",
31+
"null-loader": "^0.1.1",
32+
"raw-loader": "^0.5.1",
33+
"rimraf": "^2.6.1",
34+
"style-loader": "^0.18.2",
35+
"typescript": "^2.4.2",
36+
"webpack": "^3.5.5",
37+
"webpack-dev-server": "^2.7.1",
38+
"webpack-merge": "^4.1.0"
39+
}
40+
}

src/client/app/app.component.html

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h2>YUM Recipes - Development in progress</h2>
2+
<h3>Please check back here in a few days.</h3>

src/client/app/app.component.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app',
5+
templateUrl: './app.component.html'
6+
})
7+
8+
export class AppComponent {
9+
}

src/client/app/app.module.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { NgModule } from '@angular/core';
2+
import { BrowserModule } from '@angular/platform-browser';
3+
4+
import { AppComponent } from './app.component';
5+
6+
@NgModule({
7+
declarations: [AppComponent],
8+
imports: [BrowserModule],
9+
bootstrap: [AppComponent]
10+
})
11+
12+
export class AppModule {
13+
}

src/client/index.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<base href="/">
6+
<title>Yum Recipes</title>
7+
<meta charset="UTF-8">
8+
<meta name="viewport" content="width=device-width, initial-scale=1">
9+
</head>
10+
11+
<body>
12+
<app>Loading...</app>
13+
</body>
14+
15+
</html>

src/client/main.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2+
import { enableProdMode } from '@angular/core';
3+
4+
import { AppModule } from './app/app.module';
5+
6+
if (process.env.ENV == 'production') {
7+
enableProdMode();
8+
}
9+
10+
platformBrowserDynamic().bootstrapModule(AppModule);

src/client/polyfills.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'core-js/es6';
2+
import 'core-js/es7/reflect';
3+
require('zone.js/dist/zone');
4+
5+
if (process.env.ENV === 'production') {
6+
// Production
7+
} else {
8+
// Development and test
9+
Error['stackTraceLimit'] = Infinity;
10+
require('zone.js/dist/long-stack-trace-zone');
11+
}

src/client/tsconfig.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"sourceMap": true,
7+
"emitDecoratorMetadata": true,
8+
"experimentalDecorators": true,
9+
"lib": [
10+
"es2015",
11+
"dom"
12+
],
13+
"noImplicitAny": true,
14+
"suppressImplicitAnyIndexErrors": true,
15+
"types": [
16+
"node"
17+
],
18+
"typeRoots": [
19+
"../../node_modules/@types"
20+
]
21+
}
22+
}

src/client/vendor.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Angular
2+
import '@angular/platform-browser';
3+
import '@angular/platform-browser-dynamic';
4+
import '@angular/core';
5+
import '@angular/common';
6+
7+
// Other vendors for example jQuery, Lodash, rxjs or Bootstrap
8+
// You can import js, ts, css, sass, ...

webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require(`./config/webpack.dev.js`);

0 commit comments

Comments
 (0)