gaearon / react-hot-boilerplate

Minimal live-editing example for React
MIT License
3.91k stars 879 forks source link

How to deploy for production? #13

Closed mewben closed 8 years ago

gaearon commented 9 years ago

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.

cocodrino commented 9 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

nimamehanian commented 8 years ago

+1

tkh44 commented 8 years ago

"0" would be truthy. You can just do var PROD = !!process.env.PROD_DEV

gaearon commented 8 years ago

Yep, that’s the problem.

gaearon commented 8 years ago

Let’s track in #63.