```ruby
namespace :webpack do
  desc "Compile webpack bundles in to public/webpack"
  task compile: :environment do
    ENV["TARGET"] = 'production'
    destdir = Rails.root.join("public", "webpack")
    webpack_bin = Rails.root.join("node_modules", ".bin", "webpack")
    FileUtils.mkdir_p destdir

    system "#{webpack_bin} --json > #{destdir}/manifest.json"
  end
end
```

Use sh, not system, in rake task so it dies if it fails
user
```ruby
namespace :webpack do
  desc "Compile webpack bundles in to public/webpack"
  task compile: :environment do
    ENV["TARGET"] = 'production'
    destdir = Rails.root.join("public", "webpack")
    webpack_bin = Rails.root.join("node_modules", ".bin", "webpack")
    FileUtils.mkdir_p destdir

    sh "#{webpack_bin} --json > #{destdir}/manifest.json"
  end
end
```
assistant