title: How do I install Webpacker on Heroku with Rails 6
body: <p>I am trying to install a Rails 6 app to Heroku with Webpacker</p>
  <p>The git push heroku command seems to trigger the whole build proces</p>
  <p>The node.js is invoked successfully and completes.</p>
  <p>devDependencies then get pruned apparently.</p>
  <p>Then the ruby buildpack kicks in which installs all of the ruby gems and  &quot;detects rake tasks&quot; during which it runs rake assets:precompile</p>
  <p>Then I get:</p>
  <pre><code>Compilation failed:
  CLI for webpack must be installed.
  webpack-cli (https://github.com/webpack/webpack-cli)
  </code></pre>
  <p>I am pretty sure I need to run</p>
  <pre><code>bin/rails webpacker:install
  </code></pre>
  <p>somewhere before asset compilation starts, but there is no chance to customise the build script as there is with node.js package.json script hooks for prebuild and postbuild from what I can see and I just end up with:</p>
  <pre><code>Precompiling assets failed.
  Push rejected, failed to compile Ruby app.
  </code></pre>
  <p>So how am I supposed to get around this and get webpacker installed properly before heroku tries to compile the assets?</p>