Skip to content

Commit

Permalink
Auto-generate the index.html file
Browse files Browse the repository at this point in the history
With the html-webpack-plugin
  • Loading branch information
geowarin committed Aug 5, 2015
1 parent a3de637 commit 10e3fda
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
19 changes: 19 additions & 0 deletions frontend/assets/index-template.html
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html{% if(o.htmlWebpackPlugin.files.manifest) { %} manifest="{%= o.htmlWebpackPlugin.files.manifest %}"{% } %}>
<head>
<meta charset="UTF-8">
<title>{%=o.htmlWebpackPlugin.options.title || 'Webpack App'%}</title>
{% if (o.htmlWebpackPlugin.files.favicon) { %}
<link rel="shortcut icon" href="{%=o.htmlWebpackPlugin.files.favicon%}">
{% } %}
{% for (var css in o.htmlWebpackPlugin.files.css) { %}
<link href="{%=o.htmlWebpackPlugin.files.css[css] %}" rel="stylesheet">
{% } %}
</head>
<body>
<div id="root"></div>
{% for (var chunk in o.htmlWebpackPlugin.files.chunks) { %}
<script src="{%=o.htmlWebpackPlugin.files.chunks[chunk].entry %}"></script>
{% } %}
</body>
</html>
10 changes: 0 additions & 10 deletions frontend/index.html

This file was deleted.

13 changes: 9 additions & 4 deletions frontend/webpack.config.js
@@ -1,5 +1,6 @@
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
devtool: 'eval',
Expand All @@ -11,18 +12,22 @@ module.exports = {
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/'
publicPath: 'http://localhost:3000/'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
new webpack.NoErrorsPlugin(),
new HtmlWebpackPlugin({
title: 'Boot React',
template: path.join(__dirname, 'assets/index-template.html')
})
],
resolve: {
extensions: ['', '.js', '.jsx']
extensions: ['', '.js']
},
module: {
loaders: [{
test: /\.jsx?$/,
test: /\.js$/,
loaders: ['react-hot', 'babel'],
include: path.join(__dirname, 'src')
}]
Expand Down

0 comments on commit 10e3fda

Please sign in to comment.