Isomorphic react support #62
Comments
What are the contents of your |
I just set up an express server with a webpack-dev-middleware in the start script. I built the configuration based on gaearon's react-transform-boilerplate. |
not use babel-plugin-react-transform in .babelrc. use config in webpack.config.js module: {
loaders: [
{
test: /\.(js|jsx)$/,
loader: 'babel',
include: path.join(__dirname, 'src'),
query: {
plugins: [
["react-transform", {
transforms: [{
transform: "react-transform-hmr",
imports: ["react"],
locals: ["module"]
}, {
"transform": "react-transform-catch-errors",
"imports": ["react", "redbox-react"]
}]
}]
]
}
}
]
} it is support in isomorphic apps (y) |
@carloscuatin you are brilliant! It works. |
@carloscuatin thanks! got me up and running too 👍 |
Babel only checks the {
"presets": ["react", "es2015"],
"env": {
"development": {
... This means the plugin activates when So the solution is to tell Babel to use another configuration on the server by specifying # any of these will do!
NODE_ENV=production node app.js
NODE_ENV=server node app.js
NODE_ENV=server-development node app.js
NODE_ENV=whatever node app.js
# but not this!
node app.js We already say this in README but sadly people look over it. :-(
|
删除(delete) .bablerc => env =>"development": {"presets": ["react-hmre"]}
|
I'm trying to use it in my isomorphic react project. But I got a error when I require a jsx file.
Seems like, babel cant figure out whether the file is required in the server side or not. So it apply the
react-transform-hmr
on every jsx file.Any workarounds to solve my problem?
The text was updated successfully, but these errors were encountered: