Skip to content

Commit 9dd1a0b

Browse files
committed
update structure to run entirely on webpack
1 parent 05ef289 commit 9dd1a0b

29 files changed

+149
-49
lines changed

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.2.1
1+
6.5.0
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

client/app/polyfill.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import 'es6-shim';
2+
import 'es6-promise';
3+
import 'reflect-metadata';
4+
5+
import 'zone.js/dist/zone';
6+
import 'zone.js/dist/long-stack-trace-zone';

client/app/style.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require('todomvc-common/base.css');
2+
require('todomvc-app-css/index.css');

client/app/vendor.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import './polyfill';
2+
import 'rxjs';
3+
4+
import 'localStorage';
5+
import 'node-uuid';
6+
7+
import '@angular/platform-browser';
8+
import '@angular/forms';
9+
import '@angular/http';
10+
import '@angular/router';
11+
import '@angular/core';
File renamed without changes.

client/index.html

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Angular 2 TodoMVC</title>
6+
7+
<link rel="icon" type="image/x-icon" href="favicon.ico"/>
8+
9+
<link href="style.bundle.css" rel="stylesheet">
10+
</head>
11+
<body>
12+
<todo-app>Loading...</todo-app>
13+
14+
<a href="https://github.com/blacksonic/angular2-esnext-todomvc">
15+
<img
16+
style="position: absolute; top: 0; right: 0; border: 0; z-index: 3000;"
17+
class="github-ribbon" alt="Fork me on GitHub"
18+
src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"
19+
>
20+
</a>
21+
22+
<script src="vendor.bundle.js"></script>
23+
<script src="main.bundle.js"></script>
24+
</body>
25+
</html>

index.html

-22
This file was deleted.

package.json

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "angular2-esnext-todomvc",
33
"version": "3.0.0",
4-
"main": "app/main.js",
4+
"main": "client/app/main.js",
55
"scripts": {
6-
"start": "concurrently --kill-others 'npm run bundle' 'npm run server'",
7-
"server": "http-server -a 0.0.0.0 -p 9000",
8-
"bundle": "webpack app/main.js app/dist/main.bundle.js --config webpack.config.js --watch -d"
6+
"build": "webpack",
7+
"deploy": "gh-pages -d dist",
8+
"start": "webpack-dev-server"
99
},
1010
"repository": {
1111
"type": "git",
@@ -50,8 +50,15 @@
5050
"babel-loader": "6.2.5",
5151
"babel-preset-angular2": "0.0.2",
5252
"babel-preset-es2015": "6.14.0",
53-
"concurrently": "2.2.0",
54-
"raw-loader": "0.5.1",
55-
"webpack": "1.13.2"
53+
"copy-webpack-plugin": "3.0.1",
54+
"css-loader": "0.25.0",
55+
"extract-text-webpack-plugin": "1.0.1",
56+
"gh-pages": "0.11.0",
57+
"html-loader": "0.4.4",
58+
"progress-bar-webpack-plugin": "1.9.0",
59+
"style-loader": "0.13.1",
60+
"webpack": "1.13.2",
61+
"webpack-dev-server": "1.16.1",
62+
"webpack-merge": "0.14.1"
5663
}
5764
}

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ npm start
2929

3030
```
3131

32-
Open it in your browser [http://localhost:9000](http://localhost:9000).
32+
Open it in your browser [http://localhost:3000](http://localhost:3000).

webpack.common.config.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
'use strict';
2+
let webpack = require('webpack');
3+
let path = require('path');
4+
let ExtractTextPlugin = require('extract-text-webpack-plugin');
5+
let ProgressBarPlugin = require('progress-bar-webpack-plugin');
6+
7+
module.exports = {
8+
entry: {
9+
'main': './app/main.js',
10+
'vendor': './app/vendor.js',
11+
'style': './app/style.js',
12+
},
13+
14+
output: {
15+
path: './dist',
16+
filename: '[name].bundle.js',
17+
sourceMapFilename: '[name].map',
18+
chunkFilename: '[id].chunk.js'
19+
},
20+
21+
context: path.join(__dirname, 'client'),
22+
23+
resolve: {
24+
root: [ path.join(__dirname, 'client') ],
25+
extensions: ['', '.js']
26+
},
27+
28+
plugins: [
29+
new webpack.optimize.OccurenceOrderPlugin(true),
30+
new webpack.optimize.CommonsChunkPlugin({ name: ['main', 'vendor'], minChunks: Infinity }),
31+
new ExtractTextPlugin('style.bundle.css'),
32+
new ProgressBarPlugin()
33+
],
34+
35+
stats: {
36+
errorDetails: true,
37+
colors: true,
38+
modules: true,
39+
reasons: true
40+
},
41+
42+
module: {
43+
loaders: [
44+
{
45+
test: /\.js$/,
46+
loader: 'babel',
47+
exclude: /(node_modules)/,
48+
query: {
49+
presets: ['es2015', 'angular2']
50+
}
51+
},
52+
{ test: /\.html$/, loader: 'html?attrs=false' },
53+
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') }
54+
]
55+
}
56+
};

webpack.config.js

+33-18
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
11
'use strict';
2+
let commonConfig = require('./webpack.common.config');
3+
let webpack = require('webpack');
4+
let merge = require('webpack-merge');
5+
let CopyWebpackPlugin = require('copy-webpack-plugin');
26

3-
module.exports = {
4-
module: {
5-
loaders: [
6-
{
7-
test: /\.js$/,
8-
loader: 'babel',
9-
exclude: /node_modules/,
10-
query: {
11-
presets: ['es2015', 'angular2']
7+
if (process.env.npm_lifecycle_event == 'build' || process.env.NODE_ENV == 'production') {
8+
module.exports = merge.smart(commonConfig, {
9+
plugins: [
10+
new webpack.optimize.DedupePlugin(),
11+
new webpack.optimize.UglifyJsPlugin({
12+
compress: {
13+
warnings: false
1214
}
13-
},
14-
{
15-
test: /\.html$/,
16-
loader: 'raw'
17-
}
18-
]
19-
},
15+
}),
16+
new CopyWebpackPlugin([
17+
{ from: 'index.html' },
18+
{ from: 'favicon.ico' },
19+
{ from: 'api', to: 'api' },
20+
{ from: 'img', to: 'img' }
21+
])
22+
],
2023

21-
devtool: 'source-map'
22-
};
24+
devtool: 'source-map'
25+
});
26+
} else {
27+
module.exports = merge.smart(commonConfig, {
28+
devServer: {
29+
contentBase: './client',
30+
port: 3000,
31+
inline: true,
32+
watchOptions: { aggregateTimeout: 300, poll: 500 }
33+
},
34+
35+
devtool: 'cheap-module-source-map'
36+
});
37+
}

0 commit comments

Comments
 (0)