lib/tasks/vite.rake in vite_ruby-3.1.1 vs lib/tasks/vite.rake in vite_ruby-3.1.2

- old
+ new

@@ -7,31 +7,42 @@ namespace :vite do task :binstubs do ViteRuby.commands.install_binstubs end - desc 'Compile JavaScript packs using vite for production with digests' + desc 'Bundle frontend entrypoints using ViteRuby' task build: :'vite:verify_install' do ViteRuby.commands.build_from_task end - desc 'Remove old compiled vites' + desc 'Bundle a Node.js app from the SSR entrypoint using ViteRuby' + task build_ssr: :'vite:verify_install' do + ViteRuby.commands.build_from_task('--ssr') + end + + desc 'Bundle entrypoints using Vite Ruby (SSR only if enabled)' + task build_all: :'vite:verify_install' do + ViteRuby.commands.build_from_task + ViteRuby.commands.build_from_task('--ssr') if ViteRuby.config.ssr_build_enabled + end + + desc 'Remove old bundles created by ViteRuby' task :clean, [:keep, :age] => :'vite:verify_install' do |_, args| ViteRuby.commands.clean_from_task(args) end - desc 'Remove the vite build output directory' + desc 'Remove the build output directory for ViteRuby' task clobber: :'vite:verify_install' do ViteRuby.commands.clobber end - desc 'Verifies if ViteRuby is properly installed in this application' + desc 'Verify if ViteRuby is properly installed in the app' task :verify_install do ViteRuby.commands.verify_install end - desc 'Ensures build dependencies like Vite are installed when compiling assets' + desc 'Ensure build dependencies like Vite are installed before bundling' task :install_dependencies do system({ 'NODE_ENV' => 'development' }, 'npx ci --yes') end desc "Provide information on ViteRuby's environment" @@ -43,13 +54,13 @@ unless ENV['VITE_RUBY_SKIP_ASSETS_PRECOMPILE_EXTENSION'] == 'true' if Rake::Task.task_defined?('assets:precompile') Rake::Task['assets:precompile'].enhance do |task| prefix = task.name.split(/#|assets:precompile/).first Rake::Task["#{ prefix }vite:install_dependencies"].invoke - Rake::Task["#{ prefix }vite:build"].invoke + Rake::Task["#{ prefix }vite:build_all"].invoke end else - Rake::Task.define_task('assets:precompile' => ['vite:install_dependencies', 'vite:build']) + Rake::Task.define_task('assets:precompile' => ['vite:install_dependencies', 'vite:build_all']) end unless Rake::Task.task_defined?('assets:clean') Rake::Task.define_task('assets:clean', [:keep, :age]) end