Skip to content

Commit e9e6cd0

Browse files
authored
feat: add a task to copy the built assets from the Maglev engine to the main app (#169)
* feat: add a task to copy the built assets from the Maglev engine to the main app
1 parent 277845e commit e9e6cd0

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

lib/tasks/maglev/vite.rake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,13 @@ namespace :maglev do
5858
Maglev::Engine.vite_ruby.commands.print_info
5959
end
6060
end
61+
62+
desc "Copy the ViteRuby's public directory to the app's public directory"
63+
task copy_public_dir: :environment do
64+
output_dir_name = Maglev::Engine.vite_ruby.config.public_output_dir
65+
source_path = Maglev::Engine.root.join('public', output_dir_name)
66+
target_path = Rails.root.join('public')
67+
FileUtils.cp_r(source_path, target_path)
68+
end
6169
end
6270
end

lib/tasks/maglev_tasks.rake

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@ def within_engine_folder(&block)
66
Dir.chdir(File.join(__dir__, '..', '..'), &block)
77
end
88

9-
# Load all task files only if they haven't been loaded before
10-
Dir[File.join(__dir__, 'maglev', '*.rake')].each do |file|
11-
# Create a unique task loaded flag
12-
task_name = File.basename(file, '.rake')
13-
next if Rake::Task.task_defined?("maglev:#{task_name}:loaded")
14-
15-
load file
16-
# Create a dummy task to mark this file as loaded
17-
Rake::Task.define_task("maglev:#{task_name}:loaded")
18-
end
19-
209
unless ENV['VITE_RUBY_SKIP_ASSETS_PRECOMPILE_EXTENSION'] == 'true'
2110
if Rake::Task.task_defined?('assets:precompile')
2211
Rake::Task['assets:precompile'].enhance do |_task|

0 commit comments

Comments
 (0)