Sha256: 85c991aa4dcca0fa3bbb1ae7bedde5591e5219b49009a6c4feaf49636924748d
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
require "middleman-core" require_relative "tailwind/version" require_relative "tailwind/upstream" module Middleman module Tailwind class Error < StandardError; end class Main < Middleman::Extension option :config_path, nil, "Custom tailwind.config.js file path" option :css_path, nil, "Tailwind source css file path" option :destination_path, "source/stylesheets/tailwind.css", "Destination path for tailwind css" def initialize(app, options_hash = {}, &block) super @gem_dir = File.expand_path "../..", __dir__ @project_dir = Dir.pwd @config_path = options.config_path @css_path = options.css_path @destination_path = options.destination_path end def platform %i[cpu os].map { |m| Gem::Platform.local.send(m) }.join("-") end def executable Upstream::NATIVE_PLATFORMS[platform] end def application_css return File.join(@project_dir, @css_path) if @css_path File.join(@gem_dir, "tailwind/application.tailwind.css") end def destination File.join(@project_dir, @destination_path) end def config_file return File.join(@project_dir, @config_path) if @config_path File.join(@gem_dir, "tailwind/tailwind.config.js") end def ready exe = File.join(@gem_dir, "exe/#{executable}") cmd = "#{exe} -c #{config_file} -i #{application_css} -o #{destination}" if app.mode?(:server) Thread.new do system("#{cmd} -w", out: $stdout) end else puts "Building Tailwind CSS..." system(cmd, out: $stdout) end end end end end ::Middleman::Extensions.register(:tailwind, Middleman::Tailwind::Main)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
middleman-tailwind-0.1.0 | lib/middleman/tailwind.rb |