Skip to content

Commit 33414fa

Browse files
committed
Use html-webpack-plugin
1 parent 2dadad9 commit 33414fa

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

Diff for: README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# typescript-webpack-react-flux-boilerplate
22
The goal of this repo is to help you start when combining React and Typescript.
33
It contains implementation of simple example based on flux pattern.
4-
LESS in combination of CSS modules is used for styling components and for running, building and bundling there is powerful Webpack.
4+
LESS in combination of CSS modules is used for styling components. For running, building and bundling there is powerful Webpack.
55

66
## This boilerplate combines
77
* [Typescript 2](https://github.com/Microsoft/TypeScript)
@@ -10,15 +10,16 @@ LESS in combination of CSS modules is used for styling components and for runnin
1010
* [Flux](https://github.com/facebook/flux)
1111
* [LESS](https://github.com/less/less.js)
1212
* [CSS modules](https://github.com/css-modules/css-modules)
13-
* [Webpack](https://github.com/webpack/webpack)
13+
* [Webpack 2](https://webpack.js.org/)
14+
* [Tslint](https://palantir.github.io/tslint/)
1415

1516
## Getting started
1617
* run **npm install** to download dependencies
1718
* run **npm start** to build and start webpack-dev-server
1819
* open **http://localhost:3333/**
1920

2021
## Build options
21-
* **npm run build** for single build (creates files in build/ folder)
22+
* **npm run build** for single build (creates files and index.html in build/ folder)
2223
* **npm start** to build and start webpack-dev-server
2324

2425
## More information

Diff for: index.html

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@
55
<body>
66
<div id="root">
77
</div>
8-
<script src="/assets/vendors.js"></script>
9-
<script src="/assets/app.js"></script>
108
</body>
119
</html>

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"babel-preset-es2015-loose": "~8.0.0",
3131
"css-loader": "~0.28.0",
3232
"file-loader": "~0.11.1",
33+
"html-webpack-plugin": "~2.28.0",
3334
"less": "~2.7.2",
3435
"less-loader": "~4.0.3",
3536
"node-libs-browser": "~2.0.0",

Diff for: server.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/// <reference path="node_modules/@types/node/index.d.ts"/>
2-
31
var path = require('path');
42
var webpack = require('webpack');
53
var WebpackDevServer = require('webpack-dev-server');

Diff for: webpack.config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var path = require("path");
22
var webpack = require("webpack");
3+
var HtmlWebpackPlugin = require("html-webpack-plugin");
34

45
var nodeModulesPath = path.join(__dirname, 'node_modules');
56
var isProduction = process.env.NODE_ENV == "production";
@@ -61,7 +62,10 @@ var config = {
6162
},
6263

6364
plugins: [
64-
new webpack.optimize.CommonsChunkPlugin({ name: 'vendors', filename: 'vendors_[chunkhash].js' })
65+
new webpack.optimize.CommonsChunkPlugin({ name: 'vendors', filename: 'vendors_[hash].js' }),
66+
new HtmlWebpackPlugin({
67+
template: 'index.html'
68+
})
6569
]
6670
};
6771

Diff for: webpack.dev.config.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ var path = require("path");
66

77
var mainConfig = new Config().extend("webpack.config");
88
mainConfig.module.rules = [];
9-
mainConfig.plugins = [];
109

1110
var devConfigExtension = {
1211
entry: {
@@ -19,7 +18,7 @@ var devConfigExtension = {
1918

2019
output: {
2120
filename: '[name].js',
22-
publicPath: "http://localhost:3333/assets/"
21+
publicPath: "http://localhost:3333/"
2322
},
2423

2524
// more options here: http://webpack.github.io/docs/configuration.html#devtool
@@ -59,9 +58,8 @@ var devConfigExtension = {
5958
},
6059

6160
plugins: [
62-
new webpack.optimize.CommonsChunkPlugin({ name: 'vendors', filename: 'vendors.js' }),
6361
// Used for hot-reload
64-
new webpack.HotModuleReplacementPlugin()
62+
new webpack.HotModuleReplacementPlugin(),
6563
]
6664
};
6765

0 commit comments

Comments
 (0)