Skip to content

Commit 61812c5

Browse files
committed
Make assets.rb cleaner
1 parent 5d71f8f commit 61812c5

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Diff for: app/assets/javascripts/application_static.js.erb renamed to app/assets/javascripts/application_static.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
// CRITICAL that webpack/vendor-bundle must be BEFORE turbolinks
88
// since it is exposing jQuery and jQuery-ujs
99

10-
<% if ENV["REACT_ON_RAILS_ENV"] != "HOT" %>
11-
<% require_asset "vendor-bundle" %>
12-
<% require_asset "app-bundle" %>
13-
<% end %>
10+
//= require vendor-bundle
11+
//= require app-bundle
1412

1513
// Non-webpack assets incl turbolinks
1614
//= require application_non_webpack

Diff for: config/initializers/assets.rb

+8-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88

99
# Precompile additional assets.
1010
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11-
Rails.application.config.assets.precompile += %w(
12-
application_*.*
13-
server-bundle.js
14-
)
11+
Rails.application.config.assets.precompile << "server-bundle.js"
12+
13+
type = ENV["REACT_ON_RAILS_ENV"] == "HOT" ? "non_webpack" : "static"
14+
Rails.application.config.assets.precompile +=
15+
[
16+
"application_#{type}.js",
17+
"application_#{type}.css"
18+
]

0 commit comments

Comments
 (0)