Git Product home page Git Product logo

lita-asset-track's Introduction

lita-asset-track

Tracks webpack asset sizes referenced by manifest.json.

Allows you to register manifests and will emit hourly events with the size of each JS or CSS files.

Usage

Add to your Gemfile:

gem 'lita-asset-track'

Create a lita event handler.

require "lita-asset-track"
require "lita"

module Lita
  module Handlers
    # Subscribe to event from lita-asset-track and print the data
    class AssetSize < Handler
      on(:asset_track_size) do |payload|
        msg  = "host: #{payload[:host]}\n"
        msg += "asset: #{payload[:asset]}"
        msg += "bytes: #{payload[:bytes]}"
        msg += "bytes_gzip: #{payload[:bytes_gzip]}"
        robot.send_message(target_room, msg)
      end

      private

      def target_room
        Source.new(room: Lita::Room.find_by_name("general"))
      end
    end

    Lita.register_handler(AssetSize)
  end
end

Chat Commands

Register webpack manifests:

lita asset track add http://app1.com/manifest.json http://app2.com/manifest.json

Your subscribed block will be called roughly every hour. You can do what you want with the stats, but the intention is to use some third party service like Librato or Datadog to track size over time.

List tracked webpack manifests:

lita asset track list

Stop tracking a webpack manifests:

lita asset track remove http://app1.com/manifest.json

Developing

Write tests, run tests:

bundle exec rspec

Try integration:

bundle exec lita
> lita help

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.