npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

frontbend

v0.3.2

Published

Frontbend is a tool that automates the analysis of image dimensions accross various breakpoints.

Downloads

9

Readme

npm Build Status Build status

Frontbend

Frontbend is a tool that automates the analysis of image dimensions accross various breakpoints.

Node

Install

npm install --save-dev frontbend

Usage

const path = require('path');
const fs = require('fs');
const frontbend = require('frontbend');

const configFile = path.resolve(__dirname, 'config.json');
const outputDir = path.resolve(__dirname, 'output');
const config = JSON.parse(fs.readFileSync(configFile, 'utf8'));

frontbend
  .analyze(config)
  .then(result => frontbend.writeResult(result, outputDir));

API

const frontbend = require('frontbend');

frontbend.analyze(config [, options])

Options:

| Option | Default value | Description | | ---------- | ------------- | ---------------------------------------------------------------------------------------------- | | parallel | 1 | Increase to allow multiple image types being processed in parallel. | | open | false | Run in full version of Chromium. By default, frontbend launches Chromium in headless mode. |

frontbend.writeResult(result [, options])

Options:

| Option | Default value | Description | | ------- | ------------- | ----------------------------------------------------- | | clean | false | Delete output directory before running frontbend. |

CLI

npx frontbend ./my/config.json ./my/output/ [options]

or

npm install --global frontbend
frontbend ./my/config.json ./my/output/ [options]

Options:

| Option | Alias | Default value | Description | | ------------ | ----- | ------------- | ---------------------------------------------------------------------------------------------- | | --parallel | -p | 1 | Increase to allow multiple image types being processed in parallel. | | --open | -o | false | Run in full version of Chromium. By default, frontbend launches Chromium in headless mode. | | --clean | -c | false | Delete output directory before running frontbend. |

Configuration

policies [object<string, object>]

Use policies in order to define transformations and output quality for images delivered by Akamai Image Manager.

Example:

{
  "policies": {
    "16x9": {
      "transformations": [
        {
          "transformation": "Resize",
          "type": "normal",
          "aspect": "fill",
          "width": 3840,
          "height": 2160
        },
        {
          "gravity": "Center",
          "transformation": "Crop",
          "width": 3840,
          "height": 2160,
          "allowExpansion": false
        }
      ],
      "output": {
        "perceptualQuality": "mediumHigh"
      }
    }
  }
}

Documentation of Akamai Image Manager Policies

Note: The id and breakpoints fields are added dynamically to the resulting policy files.

viewports [object<string, object>]

Define a set of viewports/breakpoints at which the interface adapts its layout.

Fields:

| Field | Type | Default value | Required | Description | | -------------- | --------- | ------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | breakpoint | number | undefined | yes | Minimum width (pixel) of viewport | | width | number | undefined | yes | Width (pixel) of the reference viewport | | fallback | boolean | undefined | no | Use as fallback viewport, e.g. for browsers without support for <picture>-elements (If no fallback is specified, Frontbend will use the largest viewport as fallback) |

Example:

{
  "viewports": {
    "xs": {
      "breakpoint": 0,
      "width": 375
    },
    "s": {
      "breakpoint": 575,
      "width": 768
    },
    "m": {
      "breakpoint": 1024,
      "width": 1200
    },
    "l": {
      "breakpoint": 1440,
      "width": 1600,
      "fallback": true
    },
    "xl": {
      "breakpoint": 1920,
      "width": 1920
    }
  }
}

Note: Frontbend follows the mobile-first approach.

imageTypes [object<string, object>]

Provide a set of image types that respond in its own way to different viewport sizes.

| Field | Type | Default value | Required | Description | | ------------------- | --------- | ------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | url | string | undefined | yes | Url of page | | selector | string | undefined | yes | CSS Selector for the image element | | credentials | object | null | no | Provide credentials for HTTP authentication | | useRelativeUnit | boolean | true | no | Set to false in order to use an absolute unit (px) for image dimensions | | retinaScale | number | 1.5 | no | Scale factor that will be used to determine image dimensions for high resolution screens | | policy | string | 'default' | no | Id of policy that should be applied to the image | | overrides | object | undefined | no | Use the overrides object to use a different policy at specific viewports/breakpoints (e.g. when you want to switch to a different aspect ratio for particular viewports) |

Example:

{
  "imageTypes": {
    "stage": {
      "url": "http://localhost:8000/",
      "selector": ".stage__image",
      "credentials": { "username": "USERNAME", "password": "PASSWORD" },
      "policy": "16x9"
    },
    "intro": {
      "url": "http://localhost:8000/",
      "selector": ".intro__image",
      "credentials": { "username": "USERNAME", "password": "PASSWORD" },
      "policy": "1x1",
      "overrides": {
        "xs": {
          "policy": "16x9"
        }
      }
    }
  }
}

See configuration example