Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add index.html file #3

Merged
merged 2 commits into from
Jul 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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