Please enlighten me!
Let say I have the following assets structure in a Rails 5 application.
app/assets/javascripts
application.js
file1.js
In the application.js
manifest I am not requiring //= file1
neither I am using require_tree .
directive.
If a JS file is not required in any way in the manifest application.js
neither is it included in the Rails.application.config.assets.precompile += %w[]
- Is this asset going to be served?
- If there is a tag in some view
<%= javascript_include_tag 'file1' %>
, should it work or raise an error?
No, that file is not served by default. By default (depending on Rails version/asset config), only the files listed in
Rails.application.config.assets.precompile
, by default application.js application.css or in newer Sprockets/Rails via files listed inmanifest.js
are available for direct serving viajavascript_include_tag
.That 2. would raise an error.