Skip to content

Instantly share code, notes, and snippets.

@alexwilson
Created January 22, 2016 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexwilson/80fdd054b27c1386db0c to your computer and use it in GitHub Desktop.
Save alexwilson/80fdd054b27c1386db0c to your computer and use it in GitHub Desktop.
Is this doing it right?
import webpack from "webpack";
import WebpackDevServer from "webpack-dev-server";
import config from "./webpack.config";
const host = 'localhost';
const port = 9080;
config.devtool = 'eval';
config.entry.push('webpack-dev-server/client?http://'+host+':'+port);
config.entry.push('webpack/hot/only-dev-server');
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
historyApiFallback: true
}).listen(port, host, function (err, result) {
if (err) {
console.log(err);
}
console.log('Listening at '+host+':'+port);
});
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: [
'./src/index'
],
output: {
filename: 'bundle.js',
path: path.join(__dirname, 'build'),
publicPath: '/build/'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new ExtractTextPlugin('bundle.css', {
allChunks: true
})
],
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
{
test: /\.jsx?$/,
loaders: ['react-hot', 'babel-loader'],
include: path.join(__dirname, 'src'),
exclude: /node_modules/
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('css!sass')
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment