Sha256: 7db9a938135d2da9f56bb537150f6dfc3a421d8758f1162d01a2080c60deb8c9
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
namespace :css do desc "Install JavaScript dependencies" task :install do command = install_command unless system(command) raise "cssbundling-rails: Command install failed, ensure #{command.split.first} is installed" end end desc "Build your CSS bundle" build_task = task :build do command = build_command unless system(command) raise "cssbundling-rails: Command build failed, ensure `#{command}` runs without errors" end end build_task.prereqs << :install unless ENV["SKIP_YARN_INSTALL"] || ENV["SKIP_BUN_INSTALL"] end 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" 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" end def tool_exists?(tool) system "command -v #{tool} > /dev/null" end unless ENV["SKIP_CSS_BUILD"] if Rake::Task.task_defined?("assets:precompile") Rake::Task["assets:precompile"].enhance(["css:build"]) end if Rake::Task.task_defined?("test:prepare") Rake::Task["test:prepare"].enhance(["css:build"]) elsif Rake::Task.task_defined?("spec:prepare") Rake::Task["spec:prepare"].enhance(["css:build"]) elsif Rake::Task.task_defined?("db:test:prepare") Rake::Task["db:test:prepare"].enhance(["css:build"]) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cssbundling-rails-1.3.0 | lib/tasks/cssbundling/build.rake |