Skip to content

Commit

Permalink
Merge pull request #3 from mxstbr/html-file
Browse files Browse the repository at this point in the history
Add index.html file
  • Loading branch information
gaearon authored Jul 17, 2016
2 parents 4796e13 + 2b6ca02 commit 3a003be
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
11 changes: 11 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My React App</title>
</head>
<body>
<!-- A lot of magic happens in this file. HtmlWebpackPlugin automatically includes all assets (e.g. bundle.js) with the correct HTML tags, which is why they are missing in this HTML file. -->
</body>
</html>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"bin",
"scripts",
"src",
"index.html",
"webpack.config.dev.js",
"webpack.config.prod.js"
],
Expand Down
3 changes: 2 additions & 1 deletion scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ module.exports = function(hostPath, appName, verbose) {
JSON.stringify(hostPackage, null, 2)
);

// Move the src folder
// Move the files for the user
// TODO: copying might be more correct?
fs.renameSync(path.join(selfPath, 'src'), path.join(hostPath, 'src'));
fs.renameSync(path.join(selfPath, 'index.html'), path.join(hostPath, 'index.html'));

// Run another npm install for react and react-dom
// TODO: having to do two npm installs is bad, can we avoid it?
Expand Down
5 changes: 4 additions & 1 deletion webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ module.exports = {
},
plugins: [
// TODO: infer from package.json?
new HtmlWebpackPlugin({ title: 'My React Project' }),
new HtmlWebpackPlugin({
inject: true,
template: path.resolve(__dirname, relative, 'index.html'),
}),
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"' })
]
};
5 changes: 4 additions & 1 deletion webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ module.exports = {
},
plugins: [
// TODO: infer from package.json?
new HtmlWebpackPlugin({ title: 'My React Project' }),
new HtmlWebpackPlugin({
inject: true,
template: path.resolve(__dirname, relative, 'index.html'),
}),
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ compressor: { warnings: false } })
Expand Down

0 comments on commit 3a003be

Please sign in to comment.