From ea5a286741929069052ec85f27d8fd4b2ccc90ed Mon Sep 17 00:00:00 2001 From: Jure Triglav <juretriglav@gmail.com> Date: Fri, 23 Oct 2015 15:26:27 +0200 Subject: [PATCH] Correct router state/props. --- app/{client.jsx => index.js} | 3 +- app/reducers/index.js | 4 +- app/routes.jsx | 2 +- webpack/webpack.dev.config.js | 38 +---------------- webpack/webpack.prod.config.js | 78 ++++++++-------------------------- 5 files changed, 24 insertions(+), 101 deletions(-) rename app/{client.jsx => index.js} (82%) diff --git a/app/client.jsx b/app/index.js similarity index 82% rename from app/client.jsx rename to app/index.js index ed2860d7a..994fe85e7 100644 --- a/app/client.jsx +++ b/app/index.js @@ -1,10 +1,11 @@ import React from 'react' +import { render } from 'react-dom' import configureStore from './store/configureStore' import Root from './containers/Root' let store = configureStore() -React.render( +render( <Root store={store} />, document.getElementById('root') ) diff --git a/app/reducers/index.js b/app/reducers/index.js index af0a5b723..7a78b96fb 100644 --- a/app/reducers/index.js +++ b/app/reducers/index.js @@ -1,4 +1,4 @@ -import { routerStateReducer } from 'redux-router' +import { routerStateReducer as router } from 'redux-router' import { combineReducers } from 'redux' import * as ActionTypes from '../actions' @@ -49,7 +49,7 @@ function reducer (state = initialState, action) { const rootReducer = combineReducers({ reducer, errorMessage, - routerStateReducer + router }) export default rootReducer diff --git a/app/routes.jsx b/app/routes.jsx index 39f6e08f1..791ee9406 100644 --- a/app/routes.jsx +++ b/app/routes.jsx @@ -14,7 +14,7 @@ import Create from './components/Create' import Share from './components/Share' export default ( - <Route component={App}> + <Route path='/' component={App}> <Route path='/' component={Share}/> <Route path='/admin'> <Route path='manages' component={Manage} /> diff --git a/webpack/webpack.dev.config.js b/webpack/webpack.dev.config.js index 7020a4c92..e30ef031b 100644 --- a/webpack/webpack.dev.config.js +++ b/webpack/webpack.dev.config.js @@ -37,7 +37,7 @@ module.exports = [ entry: { app: ['webpack-dev-server/client?http://' + WEBPACK_HOST + ':' + WEBPACK_PORT, 'webpack/hot/dev-server', - './client' ] + './index' ] }, output: { // The output directory as absolute path @@ -71,41 +71,5 @@ module.exports = [ node: { fs: 'empty' } - }, { - // The configuration for the server-side rendering - name: 'server-side rendering', - context: path.join(__dirname, '..', 'app'), - entry: { - app: './server', - header: './elements/Header' - }, - target: 'node', - output: { - // The output directory as absolute path - path: assetsPath, - // The filename of the entry chunk as relative path inside the output.path directory - filename: '[name].server.js', - // The output path from the view of the Javascript - publicPath: publicPath, - libraryTarget: 'commonjs2' - }, - devtool: 'eval-source-map', - module: { - preLoaders: [{ - test: /\.js$|\.jsx$/, - exclude: /node_modules/, - loaders: ['eslint-loader'] - }], - loaders: commonLoaders.concat([ - { test: /\.scss$/, - loader: 'css/locals?module&localIdentName=[local]__[hash:base64:5]' + - '&sourceMap!sass?sourceMap&outputStyle=expanded' + - '&includePaths[]=' + (path.resolve(__dirname, '../node_modules')) - } - ]) - }, - resolve: { - extensions: ['', '.js', '.jsx', '.json', '.scss'] - } } ] diff --git a/webpack/webpack.prod.config.js b/webpack/webpack.prod.config.js index bb570b175..d6325ba06 100644 --- a/webpack/webpack.prod.config.js +++ b/webpack/webpack.prod.config.js @@ -1,55 +1,54 @@ -var path = require("path"); -var webpack = require("webpack"); +var path = require('path') -var assetsPath = path.join(__dirname, "..", "public", "assets"); -var publicPath = "assets/"; +var assetsPath = path.join(__dirname, '..', 'public', 'assets') +var publicPath = 'assets/' var commonLoaders = [ { test: /\.js$|\.jsx$/, - loader: "babel-loader?stage=0", - include: path.join(__dirname, "..", "app") + loader: 'babel-loader?stage=0', + include: path.join(__dirname, '..', 'app') }, - { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: "url-loader" }, - { test: /\.jpg$/, loader: "file-loader" }, - { test: /\.html$/, loader: "html-loader" }, + { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader' }, + { test: /\.jpg$/, loader: 'file-loader' }, + { test: /\.html$/, loader: 'html-loader' }, { test: /\.scss$/, loader: 'css/locals?module&localIdentName=[local]%20[hash:base64:5]' + '&sourceMap!sass?sourceMap&outputStyle=expanded' + '&includePaths[]=' + (path.resolve(__dirname, '../node_modules')) } -]; +] module.exports = [ { // The configuration for the client - name: "browser", - context: path.join(__dirname, "..", "app"), + name: 'browser', + context: path.join(__dirname, '..', 'app'), entry: { - app: "./client" + app: './client' }, output: { // The output directory as absolute path path: assetsPath, // The filename of the entry chunk as relative path inside the output.path directory - filename: "[name].js", + filename: '[name].js', // The output path from the view of the Javascript publicPath: publicPath }, - devtool: "source-map", + devtool: 'source-map', module: { preLoaders: [{ test: /\.js$|\.jsx$/, exclude: /node_modules/, - loaders: ["eslint"] + loaders: ['eslint'] }], loaders: commonLoaders }, resolve: { extensions: ['', '.react.js', '.js', '.jsx', '.scss'], modulesDirectories: [ - "app", "node_modules" + 'app', 'node_modules' ] } // }, @@ -57,49 +56,8 @@ module.exports = [ // new webpack.ProvidePlugin({React: 'react'}) // ] // // extract inline css from modules into separate files - // new ExtractTextPlugin("styles/main.css"), - // new webpack.optimize.UglifyJsPlugin() - // ] - }, { - // The configuration for the server-side rendering - name: "server-side rendering", - context: path.join(__dirname, "..", "app"), - entry: { - app: "./server", - header: "./elements/Header" - }, - target: "node", - output: { - // The output directory as absolute path - path: assetsPath, - // The filename of the entry chunk as relative path inside the output.path directory - filename: "[name].server.js", - // The output path from the view of the Javascript - publicPath: publicPath, - libraryTarget: "commonjs2" - }, - externals: [ - { - 'alt/AltContainer': true, - 'react/addons': true - } - ], - module: { - loaders: commonLoaders - }, - resolve: { - extensions: ['', '.react.js', '.js', '.jsx', '.scss'] - // modulesDirectories: [ - // "app", "node_modules" - // ] - }, - plugins: [ - new webpack.ProvidePlugin({React: 'react'}) - ] - // plugins: [ - // // extract inline css from modules into separate files - // new ExtractTextPlugin("styles/main.css"), + // new ExtractTextPlugin('styles/main.css'), // new webpack.optimize.UglifyJsPlugin() // ] } -]; +] -- GitLab