|
5 | 5 | module Requirejs
|
6 | 6 | module Rails
|
7 | 7 | class Engine < ::Rails::Engine
|
8 |
| - |
9 | 8 | ### Configuration setup
|
10 |
| - config.before_configuration do |
11 |
| - config.requirejs = Requirejs::Rails::Config.new |
12 |
| - config.requirejs.precompile = [/require\.js$/] |
13 |
| - end |
14 |
| - |
15 | 9 | config.before_initialize do |app|
|
16 | 10 | config = app.config
|
17 | 11 |
|
| 12 | + config.requirejs = Requirejs::Rails::Config.new |
| 13 | + config.requirejs.precompile = [/require\.js$/] |
| 14 | + |
18 | 15 | # Process the user config file in #before_initalization (instead of #before_configuration) so that
|
19 | 16 | # environment-specific configuration can be injected into the user configuration file
|
20 |
| - process_user_config_file(app, config) |
| 17 | + Engine.process_user_config_file(app, config) |
21 | 18 |
|
22 | 19 | config.assets.precompile += config.requirejs.precompile
|
23 | 20 |
|
24 | 21 | manifest_directory = config.assets.manifest || File.join(::Rails.public_path, config.assets.prefix)
|
25 |
| - manifest_path = File.join(manifest_directory, "rjs_manifest.yml") |
| 22 | + manifest_path = File.join(manifest_directory, "rjs_manifest.yml") |
26 | 23 | config.requirejs.manifest_path = Pathname.new(manifest_path)
|
27 | 24 | end
|
28 | 25 |
|
@@ -58,13 +55,11 @@ class Engine < ::Rails::Engine
|
58 | 55 | end
|
59 | 56 | end
|
60 | 57 |
|
61 |
| - private |
62 |
| - |
63 | 58 | # Process the user-supplied config parameters, which will be
|
64 | 59 | # merged with the default params. It should be a YAML file with
|
65 | 60 | # a single top-level hash, keys/values corresponding to require.js
|
66 | 61 | # config parameters.
|
67 |
| - def process_user_config_file(app, config) |
| 62 | + def self.process_user_config_file(app, config) |
68 | 63 | config_path = Pathname.new(app.paths["config"].first)
|
69 | 64 | config.requirejs.user_config_file = config_path+'requirejs.yml'
|
70 | 65 |
|
|
0 commit comments