christianalfoni / webpack-express-boilerplate

A boilerplate for running a Webpack workflow in Node express
MIT License
1.4k stars 292 forks source link

Not able to deploy to heroku #48

Closed techyrajeev closed 8 years ago

techyrajeev commented 8 years ago

There is no postinstall script in package.json. Local npm run build is not pushing generated files from dist to heroku remote.

christianalfoni commented 8 years ago

Hi there,

There is no Heroku implementation on this boilerplate, though you can do it by:


// Since postinstall will also run when you run npm install
// locally we make sure it only runs in production
if (process.env.NODE_ENV === 'production') {

  // We basically just create a child process that will run
  // the production bundle command
  var child_process = require('child_process');
  return child_process.exec("webpack -p --config webpack.production.config.js", function (error, stdout, stderr) {
    console.log('stdout: ' + stdout);
    console.log('stderr: ' + stderr);
    if (error !== null) {
      console.log('exec error: ' + error);
    }
  });
}

You can run that with a postinstall script. The building of the files to dist actually happens on the Heroku server. Hope this helps :)