Skip to content

Commit

Permalink
[#26] Make sure that the client production build works
Browse files Browse the repository at this point in the history
* bundle.js and other assets are set up to be served from the `/assets/` path
  • Loading branch information
jonase committed Feb 29, 2016
1 parent 2c95d92 commit cac64ea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/index.html
Expand Up @@ -7,7 +7,7 @@
</head>
<body>
<div id="root"></div>
<script type="text/javascript" src="/bundle.js"></script>
<script type="text/javascript" src="/assets/bundle.js"></script>
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700' rel='stylesheet' type='text/css'>
</body>
</html>
4 changes: 3 additions & 1 deletion client/src/store/configureStore.prod.js
@@ -1,9 +1,11 @@
import { createStore, applyMiddleware, compose } from 'redux';
import thunkMiddleware from 'redux-thunk';
import { browserHistory } from 'react-router';
import { routerMiddleware } from 'react-router-redux';
import rootReducer from '../reducers/rootReducer';

const finalCreateStore = compose(
applyMiddleware(thunkMiddleware)
applyMiddleware(thunkMiddleware, routerMiddleware(browserHistory))
)(createStore);

export default function configureStore(initialState) {
Expand Down
17 changes: 12 additions & 5 deletions client/webpack.config.js
@@ -1,9 +1,11 @@
var webpack = require('webpack');
var path = require('path');
var SystemBellPlugin = require('system-bell-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

const isProd = process.env.NODE_ENV === 'production';

const entry = process.env.NODE_ENV === 'production' ?
const entry = isProd ?
[
"./src/index.jsx"
] : [
Expand All @@ -12,13 +14,15 @@ const entry = process.env.NODE_ENV === 'production' ?
"./src/index.jsx"
];

const jsLoaders = isProd ? ["babel-loader"] : ["react-hot", "babel-loader"];

module.exports = {
entry: entry,
devtool: 'source-map',
output: {
path: __dirname,
path: path.join(__dirname, 'dist'),
filename: "bundle.js",
publicPath: '/'
publicPath: '/assets/'
},
resolve: {
extensions: ['', '.js', '.jsx']
Expand All @@ -28,7 +32,7 @@ module.exports = {
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ["react-hot", "babel-loader"]
loaders: jsLoaders
},
{
test: /\.scss$/,
Expand All @@ -38,7 +42,10 @@ module.exports = {
test: /\.css$/,
loader: "style-loader!css-loader"
},
{ test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192' }
{
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=8192'
}
]
},
plugins: [
Expand Down

0 comments on commit cac64ea

Please sign in to comment.