Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

368
Vistas
Sprockets //= require with jsbundling-rails (esbuild) - how to include JS provided by gem?

Basically, exactly as the title says. I have a gem installed that gives me some JS to use. This wasn't a problem before as I was using Sprockets + Assets pipeline.

Now, I migrated to jsbundling-rails and have literally no idea how to include that JS code provided by gem. I've spent like 10 hours searching and no luck so far.

Please, help me.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The gem would have to have a js package that can be installed with yarn/npm so that it can be imported in application.js. If it doesn't, you can setup a js file to be processed only by sprockets, like in the old days.

Add another javascript entry point that will skip esbuild and will be processed only by sprockets.

Update manifest:

// app/assets/config/manifest.js

//= link custom.js

Add //= require directive:

// app/assets/javascripts/custom.js

//= require gem_javascript

Add it to layout:

<!-- app/views/layouts/application.html.erb -->

<%= javascript_include_tag "application", "custom", "data-turbo-track": "reload", defer: true %>

Alternatively, instead of using //= require add it to javascript_include_tag:

<%= javascript_include_tag "application", "gem_javascript", "data-turbo-track": "reload", defer: true %>

Might have to add it to manifest as well for precompilation:

// app/assets/config/manifest.js

//= link gem_javascript
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda