### Run Local Development Server Source: https://github.com/ancez/static-site-builder/blob/main/README.md This command starts a local development server for your static site. The server automatically rebuilds the site and refreshes the browser when file changes are detected. It requires `bundle install` to be run first to install project dependencies. The server typically runs on port 3000, but this can be customized. ```bash cd my-site bundle install # Start development server (auto-rebuilds on file changes) rake dev:server ``` -------------------------------- ### Build Static Site Locally Source: https://github.com/ancez/static-site-builder/blob/main/guides/deployment-other.md Installs Ruby and Node.js dependencies, then builds all site assets locally. Ensure you have Ruby and Node.js installed. ```bash bundle install npm install bundle exec rake build:all ``` -------------------------------- ### Install ESBuild using npm Source: https://github.com/ancez/static-site-builder/blob/main/guides/setup-esbuild.md Installs ESBuild as a development dependency in your project using npm. This is the first step to enable JavaScript bundling and minification. ```bash npm install --save-dev esbuild ``` -------------------------------- ### Install Vercel CLI (Bash) Source: https://github.com/ancez/static-site-builder/blob/main/guides/deployment-vercel.md Installs the Vercel command-line interface globally using npm. This is an optional step if you prefer using the Vercel dashboard for deployment. ```bash npm i -g vercel ``` -------------------------------- ### Create a New Static Site Project Source: https://github.com/ancez/static-site-builder/blob/main/README.md This command initiates the creation of a new static site project using the static-site-builder CLI. It sets up the basic project structure and configuration files necessary for a new website. This is the starting point for any new project with this builder. ```bash static-site-builder new my-site ``` -------------------------------- ### Install Tailwind CSS (Bash) Source: https://github.com/ancez/static-site-builder/blob/main/guides/setup-tailwind.md Installs Tailwind CSS and its peer dependencies as development dependencies using npm. It then initializes Tailwind CSS by generating `tailwind.config.js` and `postcss.config.js`. ```bash npm install -D tailwindcss npx tailwindcss init ``` -------------------------------- ### ERB Partial Rendering Example Source: https://github.com/ancez/static-site-builder/blob/main/README.md Demonstrates how to render a partial view within an ERB template, including passing local variables. This follows Rails-like conventions for partials. ```erb <%= render partial: 'shared/header', locals: { title: 'Home' } %> ``` -------------------------------- ### Alternative Development Server with Listen Gem Source: https://context7.com/ancez/static-site-builder/llms.txt Provides an alternative development server implementation using the 'Listen' gem for efficient file watching. It starts both an HTTP server (WEBrick) and a WebSocket server for live reloading, offering a robust development environment. The server can be gracefully shut down. ```ruby require 'static_site_builder/dev_server' # Create and start development server dev_server = StaticSiteBuilder::DevServer.new( root: Dir.pwd, port: 3000, # HTTP server port ws_port: 3001 # WebSocket server port ) dev_server.start # Output: # Building site... # Compiling page: index.html... # āœ“ Created index.html # # Starting development server... # HTTP server: http://localhost:3000 # WebSocket server: ws://localhost:3001 # Watching for changes... (Ctrl+C to stop) # DevServer features: # - Uses Listen gem for efficient file watching # - Watches app/ and config/ directories # - Rebuilds on .erb, .rb, .js file changes # - Starts WebSocket server for live reload # - Starts WEBrick HTTP server for serving dist/ # - Graceful shutdown on SIGINT/SIGTERM dev_server.stop # Cleanup when done ``` -------------------------------- ### Generate New Site with CLI Source: https://context7.com/ancez/static-site-builder/llms.txt Provides a command-line interface for generating new static site projects. Users can install the gem and use the 'static-site-builder new' command or run the generator script directly from the source repository. ```bash # Install the gem gem install static-site-builder # Generate a new site static-site-builder new my-site # Or use from source git clone https://github.com/Ancez/static-site-builder cd static-site-builder bundle install ruby bin/generate my-site # Generated site includes: # - ERB templates with ActionView support # - Live reload development server # - Automatic sitemap generation # - Helper auto-loading # - Asset management ``` -------------------------------- ### Deploy Project to Vercel (Bash) Source: https://github.com/ancez/static-site-builder/blob/main/guides/deployment-vercel.md Commands to build the project locally and then deploy it to Vercel's production environment. Ensure all dependencies are installed before running the build command. ```bash # Build locally first bundle install && npm install && bundle exec rake build:all # Deploy vercel --prod ``` -------------------------------- ### Install Static Site Builder Gem Source: https://github.com/ancez/static-site-builder/blob/main/README.md Installs the static-site-builder gem using RubyGems. This is the primary method for users who want to use the builder as a dependency. ```bash gem install static-site-builder # or git clone https://github.com/Ancez/static-site-builder cd static-site-builder bundle install ``` -------------------------------- ### Create New Static Site Project Source: https://github.com/ancez/static-site-builder/blob/main/README.md Creates a new static site project. This command can be run after installing the gem or by using the builder directly from its repository. ```bash gem install static-site-builder static-site-builder new my-site ``` ```bash git clone https://github.com/Ancez/static-site-builder cd static-site-builder bundle install ruby bin/generate my-site ``` -------------------------------- ### ERB Layout Template Example Source: https://github.com/ancez/static-site-builder/blob/main/README.md Defines a basic HTML layout template using ERB. This includes structure for head, body, stylesheets, and yielding page content. It also demonstrates how to handle JavaScript sections. ```erb
<%= yield %>
<% if content_for?(:javascript) %> <%= yield(:javascript) %> <% end %> ``` -------------------------------- ### Generator Development Commands Source: https://github.com/ancez/static-site-builder/blob/main/README.md This section outlines commands for developing the static-site-builder gem itself. It includes cloning the repository, installing dependencies, running tests, and building the gem. These commands are intended for contributors or those looking to modify the builder. ```bash # Clone the repo git clone https://github.com/Ancez/static-site-builder cd static-site-builder # Install dependencies bundle install # Run tests bundle exec rspec # Build the gem gem build static-site-builder.gemspec ``` -------------------------------- ### Vercel Configuration for Static Site Builder (JSON) Source: https://github.com/ancez/static-site-builder/blob/main/guides/deployment-vercel.md Defines the build settings for Vercel to deploy the static site builder project. This includes the build command, output directory, and install command. ```json { "buildCommand": "bundle install && npm install && bundle exec rake build:all", "outputDirectory": "dist", "installCommand": "bundle install && npm install" } ``` -------------------------------- ### Development Server with Live Reload (Rake Task) Source: https://context7.com/ancez/static-site-builder/llms.txt Starts a live-reload development server using WEBrick and a custom WebSocket server. It performs an initial build and then watches for file changes to trigger automatic rebuilds and browser refreshes. The server supports routing for static files. ```ruby # Rakefile (generated by the generator) namespace :dev do desc "Start development server with auto-rebuild and live reload" task :server do require 'webrick' port = ENV['PORT'] || 3000 ws_port = ENV['WS_PORT'] || 3001 dist_dir = Pathname.new(Dir.pwd).join('dist') reload_file = Pathname.new(Dir.pwd).join('.reload') # Start WebSocket server for live reload ws_server = SiteBuilder::WebSocketServer.new(port: ws_port, reload_file: reload_file) ws_server.start # Build once with live reload enabled ENV['LIVE_RELOAD'] = 'true' ENV['WS_PORT'] = ws_port.to_s Rake::Task['build:html'].invoke puts "\nšŸš€ Starting development server at http://localhost:#{port}" puts "šŸ“” WebSocket server at ws://localhost:#{ws_port}" puts "šŸ“ Watching for changes... (Ctrl+C to stop)" puts "šŸ”„ Live reload enabled - pages will auto-refresh on changes\n" # File watcher runs in background (watches app/, config/ for .erb, .rb, .js, .css) # Rebuilds on changes and updates .reload file # HTTP server serves dist/ directory # Supports: # - / -> index.html # - /about -> about.html # - /blog/ -> blog/index.html # - /assets/*, /images/* mounted as static file handlers end end # Usage: # rake dev:server # Visit http://localhost:3000 # Changes to files trigger automatic rebuild and browser refresh ``` -------------------------------- ### GitHub Actions Workflow for Deploying to GitHub Pages Source: https://github.com/ancez/static-site-builder/blob/main/guides/deployment-github-pages.md This YAML workflow automates the deployment of a static site to GitHub Pages. It checks out the code, sets up Ruby and Node.js environments, installs project dependencies (using Bundler and npm), builds the site using a Rake task, and finally deploys the generated files to GitHub Pages. It requires the `peaceiris/actions-gh-pages` action and a `GITHUB_TOKEN` secret. ```yaml name: Deploy to GitHub Pages on: push: branches: [ main ] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: 3.4 bundler-cache: true - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: '24' cache: 'npm' - name: Install dependencies run: | bundle install npm install - name: Build site run: bundle exec rake build:all # Note: Vendor files will be automatically copied from node_modules during build - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./dist ``` -------------------------------- ### Build Static Site for Production Source: https://github.com/ancez/static-site-builder/blob/main/README.md These commands are used to build the static site for production deployment. `rake build:all` builds both assets and HTML, while `rake build:html` builds only the HTML. The output is placed in the `dist/` directory, ready for deployment to any static hosting provider. ```bash # Build everything (assets + HTML) rake build:all # Or just HTML rake build:html ``` -------------------------------- ### Configure ESBuild Build Process Source: https://github.com/ancez/static-site-builder/blob/main/guides/setup-esbuild.md Defines the ESBuild build configuration in `esbuild.config.js`. This script specifies input files, enables bundling and minification, and sets the output directory and format. It includes basic error handling to exit the process on failure. ```javascript require('esbuild').build({ entryPoints: ['app/javascript/application.js'], bundle: true, outdir: 'dist/assets/javascripts', format: 'esm', minify: true, }).catch(() => process.exit(1)) ``` -------------------------------- ### Helper Auto-Loading from App/Helpers Directory Source: https://context7.com/ancez/static-site-builder/llms.txt Illustrates the automatic loading and inclusion of helper modules defined in the 'app/helpers/' directory. This allows developers to organize reusable view logic into separate Ruby modules that become available within ERB templates. ```ruby # app/helpers/application_helper.rb module ApplicationHelper def format_date(date) date.strftime("%B %d, %Y") end def nav_link(text, path) link_to text, path, class: "nav-link" end end ``` -------------------------------- ### ERB Template Compilation with ActionView Features Source: https://context7.com/ancez/static-site-builder/llms.txt Demonstrates how to use ERB templates within Static Site Builder, showcasing ActionView features like partials, layouts, and helper methods. It also shows how to integrate the 'meta-tags' gem for SEO metadata and how page templates can inject JavaScript into the main layout. ```erb # app/views/index.html.erb # Use meta-tags gem to set SEO metadata <% set_meta_tags title: 'Home Page', description: 'Welcome to my static site', keywords: 'static site, ruby, erb' %>

Welcome

This is your generated static site.

<%= render partial: 'shared/header' %> # Looks in app/views/shared/_header.html.erb <%= render 'shared/footer' %> # Shorthand syntax # app/views/layouts/application.html.erb <%= display_meta_tags %> <%= yield %> <% if content_for?(:javascript) %> <%= yield(:javascript) %> <% end %> # Page templates can inject scripts into layout <% content_for(:javascript) do %> <% end %> # Builder automatically: # - Resolves partials relative to template directory # - Includes helpers from app/helpers/ # - Renders layout with yield for page content # - Adds template path annotations in development ``` -------------------------------- ### Generate New Static Site Project with Ruby Source: https://context7.com/ancez/static-site-builder/llms.txt Initializes a new static site project using the StaticSiteBuilder::Generator class. This creates a predefined project structure including Gemfile, Rakefile, configuration, and application directories. It requires the static_site_builder gem. ```ruby require "static_site_builder" # Generate a new site generator = StaticSiteBuilder::Generator.new("my-site") generator.generate # This creates the following structure: # my-site/ # ā”œā”€ā”€ Gemfile # Dependencies (rake, actionview, webrick, sitemap_generator) # ā”œā”€ā”€ Rakefile # Build tasks (build:all, build:html, build:css, dev:server) # ā”œā”€ā”€ config/ # │ └── sitemap.rb # Sitemap configuration # ā”œā”€ā”€ app/ # │ ā”œā”€ā”€ views/ # │ │ ā”œā”€ā”€ layouts/application.html.erb # │ │ └── index.html.erb # │ ā”œā”€ā”€ helpers/ # Auto-loaded helper modules # │ ā”œā”€ā”€ javascript/application.js # │ └── assets/stylesheets/application.css # ā”œā”€ā”€ lib/ # │ └── site_builder.rb # Self-contained builder and WebSocket server # └── public/ # Static files copied to dist/ # After generation: puts "\nNext steps:" puts " cd my-site" puts " bundle install" puts " bundle exec rake dev:server # Start development server" puts " bundle exec rake build:all # Build for deployment" ``` -------------------------------- ### Run Project Tests Source: https://github.com/ancez/static-site-builder/blob/main/README.md This command executes all tests within the static-site-builder project. It uses RSpec for unit, integration, and end-to-end testing. Running tests is crucial for ensuring the stability and correctness of the builder, especially when making changes or contributions. ```bash bundle exec rspec ``` -------------------------------- ### Helper Integration in Static Site Builder Source: https://context7.com/ancez/static-site-builder/llms.txt Automatically loads helper files (ending in _helper.rb) and includes them in the ActionView context. Module names are derived from file paths using Rails conventions. Helpers can be directly used in templates for dynamic content rendering. ```ruby # Builder automatically loads all *_helper.rb files and includes them # The module name is derived from the file name (Rails convention) # application_helper.rb -> ApplicationHelper # blog/post_helper.rb -> Blog::PostHelper # Use helpers directly in templates

Published on <%= format_date(Date.today) %>

<%= nav_link "Home", "/" %> # Builder implementation: # 1. Scans app/helpers/ for *_helper.rb files # 2. Loads each file using load() for hot reloading # 3. Derives module name from file path # 4. Includes module in ActionView context ``` -------------------------------- ### Configure Sitemap Host in Ruby Source: https://github.com/ancez/static-site-builder/blob/main/README.md This code snippet shows how to set the default host for sitemap generation using the `SitemapGenerator` gem. This configuration is essential for correctly generating absolute URLs in your sitemap. It requires the `sitemap_generator` gem to be included in your project's `Gemfile`. ```ruby SitemapGenerator::Sitemap.default_host = 'https://yourdomain.com' ``` -------------------------------- ### Sitemap Generation Configuration Source: https://context7.com/ancez/static-site-builder/llms.txt Configuration for the `sitemap_generator` gem to automatically create a sitemap.xml file. It sets the default host, sitemap path, and public output directory. The code dynamically discovers ERB templates in `app/views/`, converts their paths to URLs, and adds them to the sitemap with metadata. ```ruby require 'sitemap_generator' require 'pathname' # Configure sitemap generator SitemapGenerator::Sitemap.default_host = 'https://example.com' SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps' SitemapGenerator::Sitemap.public_path = 'dist' # Generate sitemap from all page templates # Automatically discovers pages in app/views/ (excluding layouts and partials) SitemapGenerator::Sitemap.create do views_dir = Pathname.new('app/views') if views_dir.exist? Dir.glob(views_dir.join('**', '*.html.erb')).each do |erb_file| relative_path = Pathname.new(erb_file).relative_path_from(views_dir) file_name = Pathname.new(erb_file).basename.to_s # Skip partials (start with _) and layouts if !file_name.start_with?('_') && !relative_path.to_s.start_with?('layouts/') page_name = relative_path.to_s.gsub(/\.html\.erb$/, '') # Convert to URL path # index -> / # blog/index -> /blog/ # about -> /about path = if page_name == 'index' '/' elsif page_name.end_with?('/index') "/#{page_name[0..-7]}/" else "/#{page_name}" end add path, lastmod: File.mtime(erb_file), changefreq: 'weekly', priority: 0.5 end end end end ``` -------------------------------- ### WebSocket Server for Live Reload Source: https://context7.com/ancez/static-site-builder/llms.txt Implements a WebSocket server responsible for broadcasting live reload events to connected clients. It operates by polling a specified file for changes and sending a 'reload' message when the file's modification time is updated. This enables real-time updates in the browser during development. ```ruby require 'static_site_builder/websocket_server' # Create WebSocket server for live reload ws_server = StaticSiteBuilder::WebSocketServer.new( port: 3001, reload_file: Pathname.new('.reload') ) ws_server.start # Starts in background threads: # - Accept thread: handles incoming WebSocket connections # - Watch thread: polls .reload file for changes (every 0.3s) # When builder writes to .reload file: File.write('.reload', Time.now.to_f.to_s) # WebSocket server: # 1. Detects .reload file mtime change # 2. Broadcasts "reload" message to all connected clients ``` -------------------------------- ### Cloudflare Pages Build and Deploy Commands Source: https://github.com/ancez/static-site-builder/blob/main/guides/deployment-cloudflare.md These commands define how your static site is built and deployed on Cloudflare Pages. The build command cleans and rebuilds the site into the 'dist/' directory, and the deploy command uploads these assets. ```bash bundle exec rake build:all ``` ```bash npx wrangler deploy --assets=./dist ``` ```bash npx wrangler versions upload --assets=./dist ``` -------------------------------- ### Include Bundled JavaScript in ERB Templates Source: https://github.com/ancez/static-site-builder/blob/main/guides/setup-esbuild.md Demonstrates how to include the bundled JavaScript file in your ERB templates using the `content_for` helper. This ensures the minified and bundled script is correctly referenced in the final HTML output. ```erb <% content_for :javascript do %> <% end %> ``` -------------------------------- ### Rake Build Tasks for Static Site Generation Source: https://context7.com/ancez/static-site-builder/llms.txt A set of Rake tasks to manage the static site build process. It includes tasks for cleaning the distribution directory, building assets (JavaScript, CSS), compiling HTML pages, and generating a sitemap. The 'build:all' task orchestrates the entire build process. ```ruby namespace :build do desc "Build everything (assets + HTML + CSS + sitemap)" task :all do Rake::Task['build:clean'].invoke Rake::Task['build:assets'].invoke Rake::Task['build:html'].invoke Rake::Task['build:css'].invoke Rake::Task['build:sitemap'].invoke puts "\nāœ“ Build complete!" end desc "Build JavaScript assets" task :assets do # If package.json with scripts.build exists: runs npm run build # Otherwise: copies app/javascript/ to dist/assets/javascripts/ end desc "Compile all pages to static HTML" task :html => [:assets] do builder = SiteBuilder::Builder.new(root: Dir.pwd) builder.build end desc "Build CSS (runs after HTML so dist directory exists)" task :css do # If package.json with scripts.build:css exists: runs npm run build:css # If tailwind.config.js exists: runs tailwindcss CLI # Otherwise: copies app/assets/stylesheets/ to dist/assets/stylesheets/ end desc "Clean dist directory" task :clean do dist_dir = Pathname.new(Dir.pwd).join('dist') FileUtils.rm_rf(dist_dir) if dist_dir.exist? end desc "Generate sitemap from actual pages" task :sitemap do require './config/sitemap' end end ``` -------------------------------- ### Compile ERB Templates to Static HTML with Ruby Source: https://context7.com/ancez/static-site-builder/llms.txt Compiles ERB templates into static HTML files, including asset management and optional template file name annotations. The builder outputs the compiled site to a 'dist/' directory. It requires the static_site_builder gem and can be configured with options like 'annotate_template_file_names'. Environment variables like 'PRODUCTION' can control build behavior. ```ruby require "static_site_builder" # Configure the builder builder = StaticSiteBuilder::Builder.new( root: Dir.pwd, annotate_template_file_names: true # Adds HTML comments showing template sources ) # Build the site (outputs to dist/) builder.build # Output: # Building static site... # Copying assets... # Compiling page: index.html... # āœ“ Created index.html # Copying static files from public/... # # āœ“ Build complete! Output in /path/to/dist # Annotations are auto-enabled in development (LIVE_RELOAD=true) # Production builds clean dist directory first (PRODUCTION=true) ENV["PRODUCTION"] = "true" builder.build ``` -------------------------------- ### Build CSS with Tailwind (Bash) Source: https://github.com/ancez/static-site-builder/blob/main/guides/setup-tailwind.md Compiles your Tailwind CSS for production using the `--minify` flag for a smaller file size. It takes an input CSS file and outputs a minified CSS file to the specified distribution directory. ```bash tailwindcss -i ./app/assets/stylesheets/application.css -o ./dist/assets/stylesheets/application.css --minify ``` -------------------------------- ### Enable Template Path Annotations in Ruby Source: https://context7.com/ancez/static-site-builder/llms.txt This snippet demonstrates how to enable template path annotations within a Ruby application using the StaticSiteBuilder::Builder. Annotations are useful for debugging template rendering in development environments and are automatically removed in production builds. This can be enabled manually or automatically when LIVE_RELOAD is set. ```ruby builder = StaticSiteBuilder::Builder.new( root: Dir.pwd, annotate_template_file_names: true ) ENV["LIVE_RELOAD"] = "true" ``` -------------------------------- ### Client-side JavaScript for Live Reloading Source: https://context7.com/ancez/static-site-builder/llms.txt This JavaScript snippet is injected by the builder during development to establish a WebSocket connection. When a 'reload' message is received from the server, it triggers a page reload in the browser. It includes logic to automatically reconnect on connection close. ```javascript (function() { function connect() { var ws = new WebSocket('ws://localhost:3001'); ws.onmessage = function(e) { if (e.data === 'reload') window.location.reload(); }; ws.onclose = function() { setTimeout(connect, 500); }; ws.onerror = function() {}; } connect(); })(); ``` -------------------------------- ### Define Rake Task for JavaScript Build Source: https://github.com/ancez/static-site-builder/blob/main/guides/setup-esbuild.md Adds a Rake task named `build_js` to your `Rakefile`. This task executes the ESBuild configuration script using Node.js, automating the JavaScript build process. ```ruby task :build_js do sh "node esbuild.config.js" end ``` -------------------------------- ### Meta Tags Integration with meta-tags gem Source: https://context7.com/ancez/static-site-builder/llms.txt Integrates the 'meta-tags' gem to manage SEO-friendly meta tags. This functionality is available even without a full Rails application, using an ActionController stub. Meta tags are set in ERB templates and rendered in the layout. ```erb <%# The Builder includes meta-tags gem with ActionController stub # This allows using meta-tags in standalone ActionView (no Rails needed) %> <%# app/views/index.html.erb %> <% set_meta_tags title: 'My Site - Home', description: 'A great static site', keywords: 'ruby, static site', og: { title: 'My Site', type: 'website', url: 'https://example.com', image: 'https://example.com/image.jpg' }, twitter: { card: 'summary_large_image', site: '@mysite' } %> <%# Layout renders meta tags %> <%= display_meta_tags %> <%# Outputs: My Site - Home %> <%= yield %> ``` -------------------------------- ### Include JavaScript in ERB Templates Source: https://github.com/ancez/static-site-builder/blob/main/README.md This snippet demonstrates how to include JavaScript files within an ERB template by using the `content_for` helper. This is useful for managing JavaScript assets specific to certain pages or layouts. No external dependencies are required beyond ERB templating. ```erb <% content_for(:javascript) do %> <% end %> ``` -------------------------------- ### Wrangler TOML Configuration for Cloudflare Worker Source: https://github.com/ancez/static-site-builder/blob/main/guides/deployment-cloudflare.md This TOML file configures your Cloudflare Worker, specifying its name and compatibility date. Ensure the worker name matches your Cloudflare Pages project name. ```toml name = 'your-worker-name' compatibility_date = '2025-01-22' ``` -------------------------------- ### Rake Task for Minified CSS Build (Ruby) Source: https://github.com/ancez/static-site-builder/blob/main/guides/setup-tailwind.md Defines a Rake task named `build_css` that executes the command to compile and minify Tailwind CSS for production. This simplifies the CSS build process within a Rails application. ```ruby task :build_css do sh "tailwindcss -i ./app/assets/stylesheets/application.css -o ./dist/assets/stylesheets/application.css --minify" end ``` -------------------------------- ### Watch CSS with Tailwind (Bash) Source: https://github.com/ancez/static-site-builder/blob/main/guides/setup-tailwind.md Compiles your Tailwind CSS in watch mode, automatically recompiling the CSS whenever changes are detected in your project files. This is useful for development workflows. ```bash tailwindcss -i ./app/assets/stylesheets/application.css -o ./dist/assets/stylesheets/application.css --watch ``` -------------------------------- ### Rake Task for CSS Watch Mode (Ruby) Source: https://github.com/ancez/static-site-builder/blob/main/guides/setup-tailwind.md Defines a Rake task named `watch_css` that executes the command to compile Tailwind CSS in watch mode. This allows for automatic recompilation during development, improving workflow efficiency. ```ruby task :watch_css do sh "tailwindcss -i ./app/assets/stylesheets/application.css -o ./dist/assets/stylesheets/application.css --watch" end ``` -------------------------------- ### Configure Tailwind CSS Content (JavaScript) Source: https://github.com/ancez/static-site-builder/blob/main/guides/setup-tailwind.md Configures the `tailwind.config.js` file to scan your project's template files for Tailwind class names. This ensures that only the necessary CSS is generated, leading to smaller production builds. It specifies paths to ERB and JavaScript files. ```javascript /** @type {import('tailwindcss').Config} */ module.exports = { content: [ "./app/views/**/*.{html,erb}", "./app/javascript/**/*.js", ], theme: { extend: {}, }, plugins: [], } ``` -------------------------------- ### Add Tailwind CSS Directives (CSS) Source: https://github.com/ancez/static-site-builder/blob/main/guides/setup-tailwind.md Adds the essential Tailwind CSS directives to your main stylesheet. These directives inject Tailwind's base styles, component classes, and utility classes into your project. ```css @tailwind base; @tailwind components; @tailwind utilities; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.