Closed mewben closed 8 years ago
Hi @gaearon and @mewben , I've similar question, in my webpack config I did something like this
var PROD = JSON.parse(process.env.PROD_DEV || "0");
module.exports = {
devtool: 'eval',
entry: PROD ?
[
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./scripts/index'
]
:
["./scripts/index"]
,
output: {
path: path.join(__dirname, 'build'),
filename: PROD ? "bundle.min.js" : 'bundle.js',
publicPath: '/scripts/'
},
plugins: PROD ?
[
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
(new webpack.optimize.UglifyJsPlugin({minimize: true}))
]
:
[
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]
then I run PROD_DEV=1 webpack..this generate the minified file but I notice than this still is doing request to my dev server
GET http://localhost:3000/socket.io/?EIO=3&transport=polling&t=1441324914560-29 net::ERR_CONNECTION_REFUSED
am I missing disable the server in some place?...my config file doesnt seems have other reference to the server
+1
"0" would be truthy. You can just do var PROD = !!process.env.PROD_DEV
Yep, that’s the problem.
Let’s track in #63.
Normally you'll have a separate Webpack config for production. You would remove hot replacement plugin and references to dev server there, and instead add Uglify minification plugin. Then, you'd run
webpack --config webpack.production.js
to build.