Use HTML webpack plugin for one less thing to worry about.

This commit is contained in:
Timothy Farrell 2018-01-11 16:10:51 -06:00
parent f9cb05aba1
commit a947080e0e
3 changed files with 10 additions and 6 deletions

View File

@ -35,6 +35,7 @@
"styletron-utils": "^2.5.4" "styletron-utils": "^2.5.4"
}, },
"devDependencies": { "devDependencies": {
"html-webpack-plugin": "^2.30.1",
"webpack": "~3.8.1", "webpack": "~3.8.1",
"webpack-dev-server": "~2.9.2" "webpack-dev-server": "~2.9.2"
} }

View File

@ -1,10 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/app.css"> <title>Photos</title>
</head> </head>
<body> <body>
<script src="/app.bundle.js"></script>
</body> </body>
</html> </html>

View File

@ -1,6 +1,7 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = { module.exports = {
context: path.resolve(__dirname, './src'), context: path.resolve(__dirname, './src'),
@ -31,10 +32,12 @@ module.exports = {
] ]
}, },
plugins: [ plugins: [
new webpack.DefinePlugin({ new webpack.DefinePlugin({ __DEV__: true }),
__DEV__: true new ExtractTextPlugin('app.css', { allChunks: true }),
}), new HtmlWebpackPlugin({
new ExtractTextPlugin('app.css', { allChunks: true }) template: 'index.template.html',
inject: 'body'
})
], ],
devtool: 'source-map' devtool: 'source-map'
}; };