From 378ac7b8e92a38fc9335d380e4f8b5f02a9fa392 Mon Sep 17 00:00:00 2001 From: Kevin Minehart Date: Fri, 2 Dec 2016 13:21:32 -0600 Subject: [PATCH 1/5] Delete start.js --- start.js | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 start.js diff --git a/start.js b/start.js deleted file mode 100644 index 166e2e8..0000000 --- a/start.js +++ /dev/null @@ -1,5 +0,0 @@ -// Server-side entrypoint that registers Babel's require() hook -const babelRegister = require('babel-register'); -babelRegister(); - -require('./server'); From 4567ea2a26ae175fe5dad4b0b8cc35e7100d5517 Mon Sep 17 00:00:00 2001 From: Kevin Minehart Date: Fri, 2 Dec 2016 13:21:44 -0600 Subject: [PATCH 2/5] Delete server.js --- server.js | 76 ------------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 server.js diff --git a/server.js b/server.js deleted file mode 100644 index 9627925..0000000 --- a/server.js +++ /dev/null @@ -1,76 +0,0 @@ -import express from 'express'; -const app = express(); - - -/************************************************************ - * - * Express routes for: - * - app.js - * - style.css - * - index.html - * - ************************************************************/ - -// Serve application file depending on environment -app.get('/app.js', (req, res) => { - if (process.env.PRODUCTION) { - res.sendFile(__dirname + '/build/app.js'); - } else { - res.redirect('//localhost:9090/build/app.js'); - } -}); - -// Serve aggregate stylesheet depending on environment -app.get('/style.css', (req, res) => { - if (process.env.PRODUCTION) { - res.sendFile(__dirname + '/build/style.css'); - } else { - res.redirect('//localhost:9090/build/style.css'); - } -}); - -// Serve index page -app.get('*', (req, res) => { - res.sendFile(__dirname + '/build/index.html'); -}); - - -/************************************************************* - * - * Webpack Dev Server - * - * See: http://webpack.github.io/docs/webpack-dev-server.html - * - *************************************************************/ - -if (!process.env.PRODUCTION) { - const webpack = require('webpack'); - const WebpackDevServer = require('webpack-dev-server'); - const config = require('./webpack.local.config'); - - new WebpackDevServer(webpack(config), { - publicPath: config.output.publicPath, - hot: true, - noInfo: true, - historyApiFallback: true - }).listen(9090, 'localhost', (err, result) => { - if (err) { - console.log(err); - } - }); -} - - -/****************** - * - * Express server - * - *****************/ - -const port = process.env.PORT || 8080; -const server = app.listen(port, () => { - const host = server.address().address; - const port = server.address().port; - - console.log('Essential React listening at http://%s:%s', host, port); -}); From 5a486058eb2ab130870d31da53224beba7b645e3 Mon Sep 17 00:00:00 2001 From: Kevin Minehart Date: Fri, 2 Dec 2016 13:21:56 -0600 Subject: [PATCH 3/5] Update package.json --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index ad34fa1..a9f0afb 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,6 @@ "babel-core": "^6.5.2", "babel-polyfill": "^6.5.0", "babel-runtime": "^6.5.0", - "express": "^4.12.3", "react": "^15.0.1", "react-dom": "^15.0.1", "react-router": "^2.0.0" From 966a4148049de18611cabf7bba43498845e256e7 Mon Sep 17 00:00:00 2001 From: Kevin Minehart Date: Fri, 2 Dec 2016 13:22:21 -0600 Subject: [PATCH 4/5] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a9f0afb..77070b1 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "src/main.js", "scripts": { "postinstall": "npm run build", - "server": "node start.js", + "server": "webpack-dev-server --config webpack.local.config.js", "build": "webpack -p --progress --config webpack.production.config.js", "test": "nyc ava --fail-fast --verbose --require babel-register", "coveralls": "nyc report --reporter=text-lcov | coveralls", From e1bd51e2d612c0c0d8bdf75a775b24fea10d0778 Mon Sep 17 00:00:00 2001 From: Kevin Minehart Date: Fri, 2 Dec 2016 13:25:22 -0600 Subject: [PATCH 5/5] Update webpack.local.config.js --- webpack.local.config.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/webpack.local.config.js b/webpack.local.config.js index 0604f6e..1aa488c 100644 --- a/webpack.local.config.js +++ b/webpack.local.config.js @@ -15,11 +15,16 @@ module.exports = { // Efficiently evaluate modules with source maps devtool: "eval", + + // Load the build directory on the webpack server's "/" URI + devServer: { + contentBase: "./build", + hot: true, + open: true, + }, // Set entry point to ./src/main and include necessary files for hot load entry: [ - "webpack-dev-server/client?http://localhost:9090", - "webpack/hot/only-dev-server", "./src/main" ],