Skip to content

Commit

Permalink
Use jsx extension for react components
Browse files Browse the repository at this point in the history
Lets keep defaults for for how esbuild and other build tools work with react. Its also
less configuration we have to add.
  • Loading branch information
jho406 committed Dec 31, 2024
1 parent ff3d20d commit ea2bedd
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def copy_ts_files

def copy_js_files
say "Copying application.js file to #{app_js_path}"
copy_file "#{__dir__}/templates/js/application.js", "#{app_js_path}/application.js"
copy_file "#{__dir__}/templates/js/application.jsx", "#{app_js_path}/application.jsx"

say "Copying page_to_page_mapping.js file to #{app_js_path}"
copy_file "#{__dir__}/templates/js/page_to_page_mapping.js", "#{app_js_path}/page_to_page_mapping.js"
Expand All @@ -87,8 +87,8 @@ def copy_js_files
copy_file "#{__dir__}/templates/js/application_visit.js", "#{app_js_path}/application_visit.js"

say "Copying components to #{app_js_path}"
copy_file "#{__dir__}/templates/js/inputs.js", "#{app_js_path}/components/Inputs.js"
copy_file "#{__dir__}/templates/js/layout.js", "#{app_js_path}/components/Layout.js"
copy_file "#{__dir__}/templates/js/inputs.jsx", "#{app_js_path}/components/Inputs.jsx"
copy_file "#{__dir__}/templates/js/layout.jsx", "#{app_js_path}/components/Layout.jsx"
copy_file "#{__dir__}/templates/js/components.js", "#{app_js_path}/components/index.js"

say "Copying jsconfig.json file to #{app_js_path}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def copy_js_files
filename = filename_with_tsx_extensions(view)
template "ts/" + filename, File.join("app/views", controller_file_path, filename)
else
filename = filename_with_js_extensions(view)
filename = filename_with_jsx_extensions(view)
template "js/" + filename, File.join("app/views", controller_file_path, filename)
end
end
Expand Down Expand Up @@ -148,8 +148,8 @@ def filename_with_extensions(name)
[name, :json, :props].join(".")
end

def filename_with_js_extensions(name)
[name, :js].join(".")
def filename_with_jsx_extensions(name)
[name, :jsx].join(".")
end

def filename_with_tsx_extensions(name)
Expand Down

0 comments on commit ea2bedd

Please sign in to comment.