mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
create an attribute so that webpacker can set its default path instead of hardcoding
This commit is contained in:
parent
41bc4c6207
commit
ffaee477bd
3 changed files with 4 additions and 8 deletions
|
@ -1,14 +1,13 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "rails/railtie/configuration"
|
require "rails/railtie/configuration"
|
||||||
require "yaml"
|
|
||||||
|
|
||||||
module Rails
|
module Rails
|
||||||
class Engine
|
class Engine
|
||||||
class Configuration < ::Rails::Railtie::Configuration
|
class Configuration < ::Rails::Railtie::Configuration
|
||||||
attr_reader :root
|
attr_reader :root
|
||||||
attr_accessor :middleware
|
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)
|
def initialize(root = nil)
|
||||||
super()
|
super()
|
||||||
|
@ -88,11 +87,7 @@ module Rails
|
||||||
end
|
end
|
||||||
|
|
||||||
def webpacker_path
|
def webpacker_path
|
||||||
if File.file?("#{Rails.root}/config/webpacker.yml")
|
@webpacker_path ||= "javascript"
|
||||||
YAML.load_file("#{Rails.root}/config/webpacker.yml")[Rails.env]["source_path"]&.gsub("app/", "")
|
|
||||||
else
|
|
||||||
"javascript"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1708,7 +1708,7 @@ module ApplicationTests
|
||||||
app "development"
|
app "development"
|
||||||
ActiveSupport::Dependencies.autoload_paths.each do |path|
|
ActiveSupport::Dependencies.autoload_paths.each do |path|
|
||||||
assert_not_operator path, :ends_with?, "app/assets"
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
default: &default
|
default: &default
|
||||||
|
source_path: app/javascript
|
||||||
check_yarn_integrity: false
|
check_yarn_integrity: false
|
||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
|
|
Loading…
Reference in a new issue