-
-
Notifications
You must be signed in to change notification settings - Fork 874
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
Usage of babel-register #40
Comments
We could compile the whole "start:prod": "npm run build:server && npm run build && NODE_ENV=production node ./build/server/server.js",
"build:server": "babel src --out-dir build", I've replaced the |
Will need to use webpack on the server |
Currently trying this out http://jlongster.com/Backend-Apps-with-Webpack--Part-I Will do a PR when I get it working. 👍 |
Problem is that there is no HMR on the server, even with jlongster's approach. 😦 |
How about if it was limited to production only? |
It would look something like this: // webpack.server.prod.config.js
var webpack = require('webpack')
var fs = require('fs')
var path = require('path')
module.exports = {
target: 'node',
devtool: 'inline-source-map',
entry: path.join(__dirname, 'app.js'),
output: {
filename: path.join(__dirname, 'app.bundle.js')
},
// keep node_module paths out of the bundle keep size down
externals: getExternals(),
node: {
__filename: true,
__dirname: true
},
module: {
loaders: [
{ test: /\.js$/, loader: 'babel-loader' } // handwaiving here
]
},
plugins: [
new webpack.BannerPlugin(
'require("source-map-support").install();',
{ raw: true, entryOnly: false }
)
]
}
function getExternals() {
const nodeModules = fs.readdirSync(path.resolve(__dirname, 'node_modules'))
return nodeModules.reduce((ext, mod) => {
ext[mod] = 'commonjs ' + mod
return ext
}, {})
} |
Thanks for the quick response! So basically after using this config, we need to change Another question about running in production, currently |
Pm2 is a lot of overhead. We use Throng in production. But yes we can make that change. |
Hi guys, When doing Thanks! Edit: reformulate my question: Why do we still need the |
You don’t need Node modules in prod |
Hi Jared, That's what I expected as well! So I tested with a fresh install, with
and then it fails with: Should I open a new issue or am I doing something wrong? |
For posterity: |
Hi @Grsmto, |
Hi @krystianjj, |
Thank you for quick response @Grsmto |
Anyone got this working, I don't want to take the node_modules along to the production server after creating the bundle. |
Okay, got this issue fixed in some way. We need to add this in
In order for this work in your CI pipeline, you need to make the Because, if
|
For me it not works, I get this error:
|
Hi,
Thanks for the great repo!
I have a concern about the usage of babel-register on the server.
According to babel docs, it should not be used in production.
Is there a plan to tackle this issue?
The text was updated successfully, but these errors were encountered: