Minification with Both Uglifier and esbuild

Curated ago by @jeremysmithco

Description

If you are working on legacy Rails projects with old ES5 code, but have also switched to jsbundling-rails, esbuild for new ES6 code, you may have struggled to find a good approach to minifying all your assets. Uglifier only works with ES5 and may cause issues in Harmony mode.

Inspiration for this approach came from Optionally skip compression for specific files and Custom sprockets compressor as proxy skips minified assets.

1
2
3
4
5
import Rails from "@rails/ujs"
import "@hotwired/turbo-rails"
import "./controllers"

Rails.start()