Sha256: 956345046f51842763d1cc07abb514f97a56a20e42f2b19577596f1d0b539116
Contents?: true
Size: 755 Bytes
Versions: 6
Compression:
Stored size: 755 Bytes
Contents
require 'rack' require 'listen' module Pieces class Server < Rack::Server attr_reader :path def initialize(options = {}) @path = options[:path] || Dir.pwd super end def start Pieces::Listener.new(path: path).listen super end def app files = files_to_serve(path) build_path = "#{path}/build" Rack::Builder.app do use Rack::Reloader use Rack::Static, urls: files, root: build_path, index: 'index.html' run Proc.new { |env| [404, {}, ['Not found']] } end end private def files_to_serve(path) Dir["#{path}/build/**/*"].map { |file| file.sub("#{path}/build", '') } end end end
Version data entries
6 entries across 6 versions & 1 rubygems