Skip to content

Commit 6cc901b

Browse files
mxstbrvjeux
authored andcommitted
Implement index.html to src folder
1 parent 86bdbf9 commit 6cc901b

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/index.html

Lines changed: 11 additions & 0 deletions
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>

webpack.config.dev.js

Lines changed: 4 additions & 1 deletion
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, 'src/index.html'),
80+
}),
7881
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"' })
7982
]
8083
};

webpack.config.prod.js

Lines changed: 4 additions & 1 deletion
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, 'src/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)