Skip to content

Commit

Permalink
In dev use nvm and in prod & staging use local/bin/node
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwasraj-thyagaraj committed Oct 14, 2024
1 parent 05a4214 commit 2ea4616
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion vite_ruby/default.vite.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"base": "",
"ssrBuildEnabled": false,
"ssrEntrypoint": "~/ssr/ssr.{js,ts,jsx,tsx}",
"ssrOutputDir": "public/vite-ssr"
"ssrOutputDir": "public/vite-ssr",
"nodeVersion": ""
}
8 changes: 7 additions & 1 deletion vite_ruby/lib/vite_ruby/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ def command_for(args)
exec_args, vite_args = args.partition { |arg| arg.start_with?('--node-options') }
if(File.file?('.nvmrc'))
cmd.push('sh', '-c')
cmd.push("PATH='/usr/local/node16/bin:$PATH' && #{vite_executable(*exec_args).join(' ')} #{vite_args.join(' ')}")
build_command = "#{vite_executable(*exec_args).join(' ')} #{vite_args.join(' ')}"
if(config.mode == "development")
cmd.push("source ~/.nvm/nvm.sh && nvm use && #{build_command}")
else
path = "PATH=/usr/local/node#{config.node_version}/bin:$PATH"
cmd.push("#{path} && #{build_command}")
end
else
cmd.push(*vite_executable(*exec_args))
cmd.push(*vite_args)
Expand Down

0 comments on commit 2ea4616

Please sign in to comment.