-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transition from babel-plugin-react-transform to React Hot Loader 3 #213
Comments
@standayweb i don't think that adding anyways, here is what i did to implement var path = require('path');
var getConfig = require('hjs-webpack');
var webpack = require('webpack');
var config = getConfig({
in: 'app/main.js',
out: 'dist',
clearBeforeBuild: '!(images|favicon.ico)'
});
if(process.env.NODE_ENV === 'production'){
config.plugins[4] = new webpack.optimize.UglifyJsPlugin({
mangle: {
except: ['$inject', 'elementRegistry', 'modeling']
},
compress: {
warnings: false
},
output: {
comments: false
},
sourceMap: false
});
}
if(env == 'development'){
config.entry[0] = config.entry[0] + '?reload=true';
config.entry.unshift('react-hot-loader/patch');
}
config.resolve.root = path.resolve('.');
config.module.loaders.push({
test: /\.(js|jsx|babel)$/,
loaders: ['babel', 'eslint'],
exclude: /node_modules/
});
module.exports = config; look above, i have to know to know much about where to add the
{
"presets": ["es2015", "stage-0", "react"],
"env": {
"development": {
"plugins": ["react-hot-loader/babel"]
}
}
} i had to create an import React from 'react';
import { Provider } from 'react-redux';
import getRoutes from './routes';
import {authService} from './helpers/api/auth';
function checkAuth(nextState, replace){
var nextPathName = nextState.location.pathname;
if(nextPathName == "/login"){
if(authService.loggedIn()){
replace({
pathname: '/',
state: { nextPathName: nextPathName }
});
}
}else{
if(!authService.loggedIn()){
replace({
pathname: '/login',
state: { nextPathName: nextPathName }
});
}
}
}
export default function App({store, history}){
return (
<Provider store={store}>
{getRoutes(history, checkAuth)}
</Provider>
);
} and in my import 'babel-polyfill';
import React from 'react';
import ReactDOM, {render} from 'react-dom';
import {browserHistory} from 'react-router';
import { AppContainer } from 'react-hot-loader';
import createStore from './create-store';
import App from './app';
import './styles/main.scss';
import startInitializers from './initializers';
const {store, history} = createStore(browserHistory, {});
startInitializers(store.dispatch, store.getState);
var rootEl = document.getElementById('root');
export default render(
<AppContainer>
<App store={store} history={history} />
</AppContainer>,
rootEl
);
if (module.hot) {
module.hot.accept('./app', () => {
const NextApp = require('./app').default;
render(
<AppContainer>
<NextApp store={store} history={history} />
</AppContainer>,
rootEl
);
});
} hopefully this will help you. |
TL;DR: gaearon/react-hot-boilerplate#61
babel-plugin-react-transform is now deprecated, React Hot Loader 3 is on the horizon. The biggest advantage for me right now is that I want to write more components as stateless functions but if I do, hot reloading breaks.
The text was updated successfully, but these errors were encountered: