Class: Decidim::Webpacker::Configuration
- Inherits:
-
Object
- Object
- Decidim::Webpacker::Configuration
- Defined in:
- lib/decidim/webpacker/configuration.rb
Instance Attribute Summary collapse
-
#additional_paths ⇒ Object
readonly
Returns the value of attribute additional_paths.
-
#entrypoints ⇒ Object
readonly
Returns the value of attribute entrypoints.
-
#stylesheet_imports ⇒ Object
readonly
Returns the value of attribute stylesheet_imports.
Instance Method Summary collapse
- #configuration_file ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 |
# File 'lib/decidim/webpacker/configuration.rb', line 8 def initialize @additional_paths = [] @entrypoints = {} @stylesheet_imports = {} end |
Instance Attribute Details
#additional_paths ⇒ Object (readonly)
Returns the value of attribute additional_paths.
6 7 8 |
# File 'lib/decidim/webpacker/configuration.rb', line 6 def additional_paths @additional_paths end |
#entrypoints ⇒ Object (readonly)
Returns the value of attribute entrypoints.
6 7 8 |
# File 'lib/decidim/webpacker/configuration.rb', line 6 def entrypoints @entrypoints end |
#stylesheet_imports ⇒ Object (readonly)
Returns the value of attribute stylesheet_imports.
6 7 8 |
# File 'lib/decidim/webpacker/configuration.rb', line 6 def stylesheet_imports @stylesheet_imports end |
Instance Method Details
#configuration_file ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/decidim/webpacker/configuration.rb', line 14 def configuration_file # Before webpacker is installed, the original configuration file may not # be available yet. return unless File.exist?(original_configuration_file_path) return configuration_file_path if configurations_loaded? load_asset_configurations # Read the original configuration and append the paths config = YAML.load_file(original_configuration_file_path, aliases: true) default = config["default"] || {} all_additional_paths = default["additional_paths"] || [] all_additional_paths += additional_paths all_stylesheet_imports = default["stylesheet_imports"] || {} all_stylesheet_imports.merge!(stylesheet_imports) all_entrypoints = default["entrypoints"] || {} all_entrypoints.merge!(entrypoints) config.each do |environment, env_config| config[environment] = env_config.merge( "additional_paths" => all_additional_paths, "entrypoints" => all_entrypoints, "stylesheet_imports" => all_stylesheet_imports, "compile" => (ENV.fetch("SHAKAPACKER_RUNTIME_COMPILE", "false") == "true") ) end # Write the runtime configuration and override the configuration File.write(configuration_file_path, config.to_yaml) self.configurations_loaded = true configuration_file_path end |