diff --git a/package.json b/package.json
index 749c347..5b127fa 100644
--- a/package.json
+++ b/package.json
@@ -17,10 +17,12 @@
"babel-preset-react": "6.11.1",
"babel-preset-stage-2": "6.13.0",
"chai": "3.5.0",
+ "cpy-cli": "1.0.1",
"css-loader": "0.23.1",
"eslint": "3.2.2",
"eslint-config-kentcdodds": "^9.0.0",
"ghooks": "1.3.2",
+ "html-webpack-plugin": "2.22.0",
"http-server": "0.9.0",
"karma": "1.1.2",
"karma-chai": "0.1.0",
@@ -47,9 +49,11 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "webpack --env.prod -p",
+ "postbuild": "cpy favicon.ico dist",
"prebuild:dev": "rimraf dist",
"build:dev": "webpack --env.dev",
- "start": "http-server",
+ "postbuild:dev": "cpy favicon.ico dist",
+ "start": "http-server dist",
"dev": "webpack-dev-server --env.dev --hot",
"debug": "node-nightly --inspect --debug-brk node_modules/.bin/webpack --env.debug",
"debug:dev": "npm run debug -- --env.dev",
diff --git a/index.html b/src/index.html
similarity index 97%
rename from index.html
rename to src/index.html
index 69d8dbe..a114f38 100755
--- a/index.html
+++ b/src/index.html
@@ -3,7 +3,6 @@
VanillaJS • TodoMVC
-
diff --git a/webpack.config.babel.js b/webpack.config.babel.js
index af5e69c..b5098ae 100644
--- a/webpack.config.babel.js
+++ b/webpack.config.babel.js
@@ -1,18 +1,22 @@
/* eslint no-console:"off" */
const {resolve} = require('path')
+const webpack = require('webpack')
const ProgressBarPlugin = require('progress-bar-webpack-plugin')
+const HtmlWebpackPlugin = require('html-webpack-plugin')
const webpackValidator = require('webpack-validator')
-const {getIfUtils} = require('webpack-config-utils')
+const {getIfUtils, removeEmpty} = require('webpack-config-utils')
module.exports = env => {
const {ifProd, ifNotProd} = getIfUtils(env)
const config = webpackValidator({
context: resolve('src'),
- entry: './bootstrap.js',
+ entry: {
+ app: './bootstrap.js',
+ vendor: ['todomvc-app-css/index.css'],
+ },
output: {
- filename: 'bundle.js',
+ filename: ifProd('bundle.[name].[chunkhash].js', 'bundle.[name].js'),
path: resolve('dist'),
- publicPath: '/dist/',
pathinfo: ifNotProd(),
},
devtool: ifProd('source-map', 'eval'),
@@ -22,9 +26,16 @@ module.exports = env => {
{test: /\.css$/, loaders: ['style', 'css']},
],
},
- plugins: [
- new ProgressBarPlugin()
- ],
+ plugins: removeEmpty([
+ new ProgressBarPlugin(),
+ ifProd(new webpack.optimize.CommonsChunkPlugin({
+ name: 'vendor',
+ })),
+ new HtmlWebpackPlugin({
+ template: './index.html',
+ inject: 'head',
+ }),
+ ]),
})
if (env.debug) {
console.log(config)