Skip to content

NPM Support #144

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
Next Next commit
Simplify build tool selection for bun / yarn
Simplifying ahead of introducing NPM as a build tool.
  • Loading branch information
ksylvest committed Jan 5, 2024
commit 09c7279d7196e23bca18533e26a0095c205faa0e
25 changes: 19 additions & 6 deletions lib/tasks/cssbundling/build.rake
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,28 @@ module Cssbundling
extend self

def install_command
return "bun install" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock'))
return "yarn install" if File.exist?('yarn.lock') || tool_exists?('yarn')
raise "cssbundling-rails: No suitable tool found for installing JavaScript dependencies"
case tool
when :bun then "bun install"
when :yarn then "yarn install"
else raise "cssbundling-rails: No suitable tool found for installing JavaScript dependencies"
end
end

def build_command
return "bun run build:css" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock'))
return "yarn build:css" if File.exist?('yarn.lock') || tool_exists?('yarn')
raise "cssbundling-rails: No suitable tool found for building CSS"
case tool
when :bun then "bun run build:css"
when :yarn then "yarn build:css"
else raise "cssbundling-rails: No suitable tool found for building CSS"
end
end

def tool
case
when File.exist?('bun.lockb') then :bun
when File.exist?('yarn.lock') then :yarn
when tool_exists?('bun') then :bun
when tool_exists?('yarn') then :yarn
end
end

def tool_exists?(tool)
Expand Down