Skip to content

Commit 3a003be

Browse files
authored
Merge pull request #3 from mxstbr/html-file
Add index.html file
2 parents 4796e13 + 2b6ca02 commit 3a003be

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

index.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>My React App</title>
7+
</head>
8+
<body>
9+
<!-- 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. -->
10+
</body>
11+
</html>

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"bin",
1414
"scripts",
1515
"src",
16+
"index.html",
1617
"webpack.config.dev.js",
1718
"webpack.config.prod.js"
1819
],

scripts/init.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ module.exports = function(hostPath, appName, verbose) {
3535
JSON.stringify(hostPackage, null, 2)
3636
);
3737

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

4243
// Run another npm install for react and react-dom
4344
// TODO: having to do two npm installs is bad, can we avoid it?

webpack.config.dev.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ module.exports = {
7474
},
7575
plugins: [
7676
// TODO: infer from package.json?
77-
new HtmlWebpackPlugin({ title: 'My React Project' }),
77+
new HtmlWebpackPlugin({
78+
inject: true,
79+
template: path.resolve(__dirname, relative, 'index.html'),
80+
}),
7881
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"' })
7982
]
8083
};

webpack.config.prod.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ module.exports = {
7474
},
7575
plugins: [
7676
// TODO: infer from package.json?
77-
new HtmlWebpackPlugin({ title: 'My React Project' }),
77+
new HtmlWebpackPlugin({
78+
inject: true,
79+
template: path.resolve(__dirname, relative, 'index.html'),
80+
}),
7881
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }),
7982
new webpack.optimize.OccurrenceOrderPlugin(),
8083
new webpack.optimize.UglifyJsPlugin({ compressor: { warnings: false } })

0 commit comments

Comments
 (0)