Skip to content

feat: add a task to copy the built assets from the Maglev engine to the main app #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/tasks/maglev/vite.rake
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,13 @@ namespace :maglev do
Maglev::Engine.vite_ruby.commands.print_info
end
end

desc "Copy the ViteRuby's public directory to the app's public directory"
task copy_public_dir: :environment do
output_dir_name = Maglev::Engine.vite_ruby.config.public_output_dir
source_path = Maglev::Engine.root.join('public', output_dir_name)
target_path = Rails.root.join('public')
FileUtils.cp_r(source_path, target_path)
end
end
end
11 changes: 0 additions & 11 deletions lib/tasks/maglev_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@ def within_engine_folder(&block)
Dir.chdir(File.join(__dir__, '..', '..'), &block)
end

# Load all task files only if they haven't been loaded before
Dir[File.join(__dir__, 'maglev', '*.rake')].each do |file|
# Create a unique task loaded flag
task_name = File.basename(file, '.rake')
next if Rake::Task.task_defined?("maglev:#{task_name}:loaded")

load file
# Create a dummy task to mark this file as loaded
Rake::Task.define_task("maglev:#{task_name}:loaded")
end

unless ENV['VITE_RUBY_SKIP_ASSETS_PRECOMPILE_EXTENSION'] == 'true'
if Rake::Task.task_defined?('assets:precompile')
Rake::Task['assets:precompile'].enhance do |_task|
Expand Down