rails / importmap-rails

Use ESM with importmap to manage modern JavaScript in Rails without transpiling or bundling.
MIT License
1.05k stars 113 forks source link

how to use importmap with javascript that is downloaded by ourselves? #132

Closed laptopmutia closed 1 year ago

laptopmutia commented 2 years ago

I try to implement a theme and html5 templates from themeforest and it has its own javascript files

how to pin these files into rails app with importmaps?

what I'm currently trying to do is I create javascripts folders app/assets/javascripts/*.js and put all the javascript files there

then in my importmap.rb I append this line pin_all_from "app/assets/javascripts", under: "javascripts"

idk if this gonna works, I will update this tomorrow, can't check it right know since suddenly my occular migraine/stocoma is showing up

laptopmutia commented 2 years ago

so what I need to do is add this into the importmap.rb pin_all_from "app/assets/javascripts"

then add this into the assets/config/manifest.js //= link_tree ../javascripts

now all the files will be loaded but the javascripts still not working

to make it works you need to import all the files inside app/assets/javascripts to app/javascript/application.js

so if its has TweenMax.min.js

add this

import "TweenMax.min"