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

@duxet/webpack-web-app-manifest-plugin

v2.2.0

Published

webpack-web-app-manifest-plugin is a webpack plugin that generates a PWA manifest and integrates with the assets JSON generated by assets-webpack-plugin.

Downloads

14

Readme

webpack-web-app-manifest-plugin logo

webpack-web-app-manifest-plugin

webpack-web-app-manifest-plugin is a webpack plugin that generates a PWA manifest and integrates with the assets JSON generated by assets-webpack-plugin.

How to install it

npm install --save-dev webpack-web-app-manifest-plugin

or

yarn add webpack-web-app-manifest-plugin --dev

Using it the easy way

Name all of your icon files manifest/icon_[square dimension].(png|jpeg|jpg). If you have a different naming scheme for your files, check out the section Using it the hard way below.

In your webpack config file:

import AppManifestPlugin from 'webpack-web-app-manifest-plugin';

...

plugins: [
  new AppManifestPlugin({
    content: {
      name: 'Tumblr',
      short_name: 'Tumblr',
      background_color: '#36465d',
    },
    destination: '/manifest',
  }),
],

...

To access the app manifest file path from your asset manifest:

const manifest = // however you usually access your asset manifest in code
const appManifestPath = manifest['app-manifest'].json;

...

<link rel="manifest" href={appManifestPath} />

Using it the hard way

If you don't want to name your icons based on our naming scheme, you will want to implement a few functions that are passed into the plugin.

isAssetManifestIcon()

isAssetManifestIcon is a function to determine if a webpack asset should be included as an icon in the web app manifest. The function accepts a filename parameter and returns true or false.

For example, if you only wanted to include a specific list of files, you could implement it like this:

plugins: [
  new AppManifestPlugin({
    ...
    isAssetManifestIcon: (fileName) => ['myIcon1.png', 'myIcon2.png'].indexOf(fileName) >= 0,
  }),
],

getIconSize()

getIconSize is a function to determine the icon size of any asset that passes the check isAssetManifestIcon(). The function accepts a fileName parameter and returns an object { width, height }.

For example, if you wanted to hardcode a list of sizes for your icons, you could implement it like this:

const iconSizes = {
  'myIcon1.png': { width: 120, height: 120},
  'myIcon2.png': { width: 80, height: 80},
};

...

plugins: [
  new AppManifestPlugin({
    ...
    getIconSize: (fileName) => iconSizes[fileName],
  }),
],

getIconType()

getIconType is a function to determine the type of any asset that passes the check isAssetManifestIcon(). The function accepts a fileName parameter and returns a string describing the mime type of the asset, ex. "image/png".

For example, if you wanted to hardcode a list of mime types for your icons, you could implement it like this:

const iconTypes = { 'myIcon1.png': 'image/png', 'myIcon2.jpg': 'image/jpeg' };

...

plugins: [
  new AppManifestPlugin({
    ...
    getIconType: (fileName) => iconTypes[fileName],
  }),
],