Class: Brut::CLI::Apps::BuildAssets::CSS
- Defined in:
- lib/brut/cli/apps/build_assets.rb
Instance Method Summary collapse
Methods inherited from Command
#after_bootstrap, args, #args, #before_execute, command_name, default_env, #delegate_to_commands, description, detailed_description, env_var, #err, #global_options, #handle_bootstrap_exception, #initialize, name_matches?, option_parser, #options, opts, #out, requires_project_env, requires_project_env?, #system!
Methods included from Framework::Errors
Methods included from I18n::ForCLI
Methods included from I18n::BaseMethods
#l, #t, #t_direct, #this_field_value
Methods included from ExecutionResults
#abort_execution, #as_execution_result, #cli_usage_error, #continue_execution, #show_cli_usage, #stop_execution
Constructor Details
This class inherits a constructor from Brut::CLI::Command
Instance Method Details
#execute ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/brut/cli/apps/build_assets.rb', line 50 def execute css_bundle = Brut.container.css_bundle_output_dir / "styles.css" css_bundle_source = Brut.container.front_end_src_dir / "css" / "index.css" = Brut.container.tmp_dir / "build-css-meta.json" = Brut.container. if .clean?(default: .env != "production") out.puts "Cleaning old CSS files from #{Brut.container.css_bundle_output_dir}" Dir[Brut.container.css_bundle_output_dir / "*.*"].each do |file| if File.file?(file) out.puts "Deleting #{file}" FileUtils.rm(file) end end end command = "npx esbuild --loader:.ttf=copy --loader:.otf=copy --metafile=#{} --entry-names=[name]-[hash] --sourcemap --bundle #{css_bundle_source} --outfile=#{css_bundle}" out.puts "Building CSS bundle '#{css_bundle}' with '#{command}'" system!(command) if !File.exist?() err.puts "'#{}' was not generated - cannot continue" exit 1 end = Brut::FrontEnd::AssetMetadata.new(asset_metadata_file:,out:) .merge!(extension: ".css", esbuild_metafile:) .save! end |