'Rails 7. How do I insert existing script into HTML template using Import Maps?

In my application.html.erb I have multiple existent script coming from a bootstrap template(predefined script), normally I put this code under de body tag, for example:

  <body>
    <script src="assets/plugins/custom/datatables/datatables.bundle.js"></script>
    <script src="assets/plugins/custom/vis-timeline/vis-timeline.bundle.js"></script>
    <script src="https://cdn.amcharts.com/lib/5/index.js"></script>
    <script src="assets/js/widgets.bundle.js"></script>
    <script src="assets/js/custom/widgets.js"></script>
  </body> 

In another rails version this working fine, but I am using rails 7 and I'd like to use importmap for the scripts to run properly.

If anyone knows a solution on how to import the scripts correctly so that they work and could help me, I'd be very happy.

Thanks for reading and have a funny day.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source