Sprockets - how to require a subdirectory in vendor / javascripts

I have a javascript library that I injected into the / javascripts vendor, some of them have more than one file, so I split them into directories, for example:

-- vendor -- assets -- javascripts -- jquery-zAccordion -- jquery-file-uploader 

And I would like to require the jquery-zAccordion and jquery-file-uploader in my application.js application, and I found: https://github.com/sstephenson/sprockets/issues/183#issuecomment-2007808 .

I would like to ask if 5 months have passed, is there a solution for this, or do I still need to use a workaround for using a proxy file?

+4
source share
3 answers

In the application.js file, you can include the following:

 //= require_tree ../../../vendor/assets/javascripts 

And also for entries, you can do the same for style sheets in application.css:

 *= require_tree ../../../vendor/assets/stylesheets 
+4
source

I think you need to expand the path to resources like this in the config / application.rb file

 config.assets.paths << "#{Rails.root}/vendor/assets/javascripts/jquery-zAccordion" 

@RyanBigg correct me if I am wrong.

+2
source

This should do it:

 //= require_directory ./jquery-zAccordion 
-one
source

Source: https://habr.com/ru/post/1396545/


All Articles