1
0
Fork 0
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:
Andrew Kress 2019-07-29 10:21:05 -05:00
parent 41bc4c6207
commit ffaee477bd
3 changed files with 4 additions and 8 deletions

View file

@ -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

View file

@ -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

View file

@ -1,4 +1,5 @@
default: &default
source_path: app/javascript
check_yarn_integrity: false
development:
<<: *default