Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ var express = require('express');
var app = express();
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');
var buildConfig = require('./webpack.config')


var host = 'react-koans-etherealite.c9users.io';
var webpackPort = 8081;
var webpackHostname= `${host}:${webpackPort}`;
var config = buildConfig(webpackHostname);


app.get('/app.js', function (req, res) {
res.redirect('//localhost:9090/build/app.js');
res.redirect(`//${webpackHostname}/build/app.js`);
});

app.get('/', function (req, res) {
Expand All @@ -19,7 +26,7 @@ new WebpackDevServer(webpack(config), {
hot: true,
noInfo: true,
historyApiFallback: true
}).listen(9090, 'localhost', function (err, result) {
}).listen(webpackPort, process.env.IP, function (err, result) {
if (err) {
console.log(err);
}
Expand Down
57 changes: 29 additions & 28 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
var webpack = require('webpack');
var path = require('path');

module.exports = {

entry: [
'webpack-dev-server/client?http://localhost:9090',
'webpack/hot/only-dev-server',
'./exercises/main'
],

output: {
path: __dirname + '/build/',
filename: 'app.js',
publicPath: 'http://localhost:9090/build/'
},

module: {
loaders: [
{ test: path.join(__dirname, 'exercises'), loaders: ['react-hot', 'babel-loader']}
module.exports = function(hostname) {
return {
entry: [
'webpack-dev-server/client?' + `http://${hostname}`,
'webpack/hot/only-dev-server',
'./exercises/main'
],

output: {
path: __dirname + '/build/',
filename: 'app.js',
publicPath: 'http://' + hostname + '/build/',
},

module: {
loaders: [
{ test: path.join(__dirname, 'exercises'), loaders: ['react-hot', 'babel-loader']}
]
},

resolve: {
extensions: ['', '.js', '.jsx']
},

plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]
},

resolve: {
extensions: ['', '.js', '.jsx']
},

plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]
}
}
}