Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
Malte W committed Oct 4, 2015
1 parent 1f8d25d commit 9c948db
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 20 deletions.
3 changes: 2 additions & 1 deletion examples/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "Simple example",
"main": "server.js",
"scripts": {
"start": "node server.js"
"start": "NODE_ENV=development node server.js",
"build": "NODE_ENV=production ./node_modules/.bin/webpack"
},
"repository": {
"type": "git",
Expand Down
67 changes: 48 additions & 19 deletions examples/simple/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,67 @@
var path = require('path');
var webpack = require('webpack');

var entry = [];
if(process.env.NODE_ENV === 'development') {
entry.push(
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server'
);
}

var plugins = [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
];
if(process.env.NODE_ENV === 'production') {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
);
}

var loaders = [];
if(process.env.NODE_ENV === 'development') {
loaders.push({
test: /\.js$/,
loaders: ['react-hot', 'babel'],
exclude: /node_modules/,
include: __dirname
});
} else {
loaders.push({
test: /\.js$/,
loaders: ['babel'],
exclude: /node_modules/,
include: __dirname
});
}

loaders.push({
test: /\.js$/,
loaders: ['babel'],
include: path.join(__dirname, '..', '..', 'src')
});

module.exports = {
devtool: 'eval',
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./index'
],
entry: entry.concat('./index'),
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
plugins: plugins,
resolve: {
alias: {
'react-custom-scrollbars': path.join(__dirname, '..', '..', 'src')
},
extensions: ['', '.js']
},
module: {
loaders: [{
test: /\.js$/,
loaders: ['react-hot', 'babel'],
exclude: /node_modules/,
include: __dirname
}, {
test: /\.js$/,
loaders: ['babel'],
include: path.join(__dirname, '..', '..', 'src')
}]
loaders: loaders
}
};

0 comments on commit 9c948db

Please sign in to comment.