File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change 1
1
require "rails"
2
- require "rails/railtie"
3
2
require "active_support/ordered_options"
4
3
5
- # FIXME: There's gotta be a better way than this hack?
6
- class Rails ::Engine < Rails ::Railtie
7
- initializer "propshaft.append_assets_path" , group : :all do |app |
8
- app . config . assets . paths . unshift ( *paths [ "vendor/assets" ] . existent_directories )
9
- app . config . assets . paths . unshift ( *paths [ "lib/assets" ] . existent_directories )
10
- app . config . assets . paths . unshift ( *paths [ "app/assets" ] . existent_directories )
11
- end
12
- end
13
-
14
4
module Propshaft
15
5
class Railtie < ::Rails ::Railtie
16
6
config . assets = ActiveSupport ::OrderedOptions . new
@@ -23,6 +13,15 @@ class Railtie < ::Rails::Railtie
23
13
]
24
14
config . assets . sweep_cache = Rails . env . development?
25
15
16
+ # Register propshaft initializer to copy the assets path in all the Rails Engines.
17
+ # This makes possible for us to keep all `assets` config in this Railtie, but still
18
+ # allow engines to automatically register their own paths.
19
+ Rails ::Engine . initializer "propshaft.append_assets_path" , group : :all do |app |
20
+ app . config . assets . paths . unshift ( *paths [ "vendor/assets" ] . existent_directories )
21
+ app . config . assets . paths . unshift ( *paths [ "lib/assets" ] . existent_directories )
22
+ app . config . assets . paths . unshift ( *paths [ "app/assets" ] . existent_directories )
23
+ end
24
+
26
25
config . after_initialize do |app |
27
26
config . assets . output_path ||=
28
27
Pathname . new ( File . join ( app . config . paths [ "public" ] . first , app . config . assets . prefix ) )
You can’t perform that action at this time.
0 commit comments