Skip to content
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

feat: allow skipping dependency install in assets:precompile #451

Merged
merged 1 commit into from
Jun 7, 2024
Merged
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
3 changes: 3 additions & 0 deletions docs/src/guide/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ along the `assets:precompile` rake task.
You can disable the extension of the `assets:precompile` rake task by setting
the `VITE_RUBY_SKIP_ASSETS_PRECOMPILE_EXTENSION` environment variable to `true`.

By default, dependencies will be automatically installed as part of the `assets:precompile` extension.
Set `VITE_RUBY_SKIP_ASSETS_PRECOMPILE_INSTALL` to `true` to skip dependency installation.

## Compressing Assets 📦

Most CDN and edge service providers will automatically serve compressed assets,
Expand Down
10 changes: 8 additions & 2 deletions vite_ruby/lib/tasks/vite.rake
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ 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
unless ENV['VITE_RUBY_SKIP_ASSETS_PRECOMPILE_INSTALL'] == 'true'
Rake::Task["#{ prefix }vite:install_dependencies"].invoke
end
Rake::Task["#{ prefix }vite:build_all"].invoke
end
else
desc 'Bundle Vite assets'
Rake::Task.define_task('assets:precompile' => ['vite:install_dependencies', 'vite:build_all'])
if ENV['VITE_RUBY_SKIP_ASSETS_PRECOMPILE_INSTALL'] == 'true'
Rake::Task.define_task('assets:precompile' => 'vite:build_all')
else
Rake::Task.define_task('assets:precompile' => ['vite:install_dependencies', 'vite:build_all'])
end
end

unless Rake::Task.task_defined?('assets:clean')
Expand Down
Loading