Sha256: 1e8dd5709490f9302d252679d8d4fdc9b0cf6fadcf9f0828d5ce7f5fd0e5f8b8

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require "vite_ruby"

ViteRuby.install_tasks

desc "Precompile assets"
task :environment do
  require "./config/boot"

  Staticky.application.monitor(:builder, methods: %i[call]) do |event|
    Staticky.logger.info "Built site in #{event[:time]}ms"
  end
end

namespace :site do
  desc "Build the site and its assets into the Staticky.build_path (./build)"
  task build: :environment do
    Staticky.logger.info "Building site in #{Staticky.env.name} environment..."
    Staticky.builder.call
  end

  desc "Watch the site and its assets for changes"
  task watch: :environment do
    require "filewatcher"

    Rake::Task["site:build"].execute unless Staticky.build_path.exist?

    Staticky.logger.info "Watching site in #{Staticky.env.name} environment..."

    Filewatcher.new(
      [
        "app/**/*.rb",
        "lib/**/*.rb",
        "content/**/*"
      ]
    ).watch do
      Staticky.logger.info "Change detected, rebuilding site..."
      sh("bin/rake site:build") do |ok, res|
        unless ok
          Staticky.logger.error "Error rebuilding site:"
          puts res
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
staticky-0.2.0 site_template/Rakefile