Skip to content

Commit

Permalink
fix: prevent yarn 2+ error in assets:precompile (#241)
Browse files Browse the repository at this point in the history
Yarn's migration guide mentions that selecting which dependencies are installed (dev or prod) requires the
workspace-tools plugin.

It's now the user's responsibility to ensure any build dependencies are available when vite build is run.
  • Loading branch information
pftg authored Aug 28, 2022
1 parent e738829 commit e7e857a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vite_ruby/lib/tasks/vite.rake
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,8 @@ if ARGV.include?('assets:precompile')
else
ENV['NPM_CONFIG_INCLUDE'] = 'dev'
end
ENV['YARN_PRODUCTION'] = 'false'

unless ViteRuby.commands.next_yarn?
ENV['YARN_PRODUCTION'] = 'false'
end
end
4 changes: 4 additions & 0 deletions vite_ruby/lib/vite_ruby/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def legacy_npm_version?
`npm --version`.to_i < 7 rescue false
end

def next_yarn?
`yarn --version`.to_i >= 2 rescue false
end

# Internal: Verifies if ViteRuby is properly installed.
def verify_install
unless File.exist?(config.root.join('bin/vite'))
Expand Down

0 comments on commit e7e857a

Please sign in to comment.