New Discussion

Notifications

You’re not receiving notifications from this thread.

How to import javascript from Gems with webpacker

4
Ruby

Ive come across an issue where some gems I want to use (specifically social-share-button) need to have a javascript file imported but with webpacker in rails 6, not quite sure how to do that now

Just import it in app/javascripts/packs/application.js

import "../myfile"

And put your code in app/javascripts/myfile.js

Also check out https://gorails.com/episodes/webpacker-javascript-in-rails-6

ok so just downloaded the javascript file from the gem and did that and everything works...thanks

Yep, you can do that. Or if they have a node package, you can use that instead.

How to use in the project?

Join the discussion
Create an account Log in

Learning Ruby on Rails? Join our newsletter.

We won't send you spam. Unsubscribe at any time.