From ffaee477bde1aaca2c173b3e7e58a827acbd027d Mon Sep 17 00:00:00 2001 From: Andrew Kress Date: Mon, 29 Jul 2019 10:21:05 -0500 Subject: [PATCH] create an attribute so that webpacker can set its default path instead of hardcoding --- railties/lib/rails/engine/configuration.rb | 9 ++------- railties/test/application/configuration_test.rb | 2 +- railties/test/isolation/assets/config/webpacker.yml | 1 + 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index 612bd170c6..df31862554 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -1,14 +1,13 @@ # frozen_string_literal: true require "rails/railtie/configuration" -require "yaml" module Rails class Engine class Configuration < ::Rails::Railtie::Configuration attr_reader :root attr_accessor :middleware - attr_writer :eager_load_paths, :autoload_once_paths, :autoload_paths + attr_writer :eager_load_paths, :autoload_once_paths, :autoload_paths, :webpacker_path def initialize(root = nil) super() @@ -88,11 +87,7 @@ module Rails end def webpacker_path - if File.file?("#{Rails.root}/config/webpacker.yml") - YAML.load_file("#{Rails.root}/config/webpacker.yml")[Rails.env]["source_path"]&.gsub("app/", "") - else - "javascript" - end + @webpacker_path ||= "javascript" end end end diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 38dda20bec..96678c395c 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -1708,7 +1708,7 @@ module ApplicationTests app "development" ActiveSupport::Dependencies.autoload_paths.each do |path| assert_not_operator path, :ends_with?, "app/assets" - assert_not_operator path, :ends_with?, "app/#{Rails.configuration.webpacker_path}" + assert_not_operator path, :ends_with?, "app/javascript" end end diff --git a/railties/test/isolation/assets/config/webpacker.yml b/railties/test/isolation/assets/config/webpacker.yml index 0b1f43a407..7dfae999c1 100644 --- a/railties/test/isolation/assets/config/webpacker.yml +++ b/railties/test/isolation/assets/config/webpacker.yml @@ -1,4 +1,5 @@ default: &default + source_path: app/javascript check_yarn_integrity: false development: <<: *default