Giter Club home page Giter Club logo

elegantapp / pwa-asset-generator Goto Github PK

View Code? Open in Web Editor NEW
2.6K 20.0 134.0 33.76 MB

Automates PWA asset generation and image declaration. Automatically generates icon and splash screen images, favicons and mstile images. Updates manifest.json and index.html files with the generated images according to Web App Manifest specs and Apple Human Interface guidelines.

License: MIT License

JavaScript 2.33% TypeScript 96.90% HTML 0.60% Shell 0.17%
pwa splash-screen icon manifest launch-image puppeteer ios android pwa-assets splash-screens

pwa-asset-generator's Introduction

pwa-asset-generator ✨

npm node Build Status semantic-release open-collective

Automates PWA asset generation and image declaration. Automatically generates icon and splash screen images, favicons and mstile images. Updates manifest.json and index.html files with the generated images according to Web App Manifest specs and Apple Human Interface guidelines.

Usage demonstration

A PWA on iOS with icons and splash screens

When you build a PWA with a goal of providing native-like experiences on multiple platforms and stores, you need to meet with the criteria of those platforms and stores with your PWA assets; icon sizes and splash screens. Such criteria are;

  • Google's Android platform respects Web App Manifest API specs, and it expects you to provide at least 2 icon sizes in your manifest file - https://web.dev/add-manifest/#icons 🤔

  • Apple's iOS currently doesn't support Web App Manifest API specs. You need to introduce custom html tags to set icons and splash screens to your PWA 🤔

    • You need to introduce a special html link tag with rel apple-touch-icon to provide icons for your PWA when it's added to home screen. Read more about it on Apple's Icon Guidelines and Safari Web Content Guide.
    • You need to introduce a special html link tag with rel apple-touch-startup-image to provide a splash screen for your PWA to display when it's opened and in the background. You need to create a splash screen image for every resolution on Apple's Launch Screen Guidelines and html tag with media attr for each image like <link rel="apple-touch-startup-image" href="temp/apple-splash-2048-2732.png" media="(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">. Unfortunately, this requirement is not documented on the Safari Web Content Guide sufficiently.

Creating icon and splash screen images for all the platforms, maintaining sizes and quality for all and adding html tags for each image can be overwhelming. So, why not automate it? 💡

Features

PWA Asset Generator automates the image generation in a creative way. Having Puppeteer at its core enables lots of possibilities.

  • Generates both icons and splash screens with optional --icon-only --splash-only --landscape-only and --portrait-only flags ✨

  • Updates your manifest.json and index.html files automatically for declaring generated image assets 🙌

  • Scrapes the latest specs from Apple Human Interface guidelines website via Puppeteer to make your PWA ready for all/recent iOS devices out there 🤖

    • Supports offline mode and uses static spec data when things go wrong with scraping 📴
    • Updates static spec data before each release automatically and monitors spec changes everyday 🔄
  • Uses the Chrome browser as it’s a canvas of your fav image editor. It uses a shell HTML on the fly as an art board and centers your logo before taking screenshots for each resolution via Puppeteer 🤖

  • You can provide your source in multiple formats; a local image file, a local HTML file, a remote image or HTML file 🙌

    • When it’s an image source, it is centered over the background option you provide 🌅
    • When it’s an HTML source, you can go as creative as you like; position your logo, use SVG filters, use variable fonts, use gradient backgrounds, use media queries while generating dark mode splash screens, use typography and etc. Your HTML file is rendered on Chrome before taking screenshots for each resolution 🎨
  • Uses puppeteer-core instead of puppeteer and only installs Chromium if it doesn't exist on the system. Saves waste of ~110-150mb of disk space and many seconds from the world per each user 🌎⚡️

  • Supports dark mode splash screens on iOS! So, you can provide both light 🌕 and dark 🌚 splash screen images to differentiate your apps look & feel based on user preference 🌙

  • Supports PWA maskable icons by declaring them in manifest file adaptively 🖼

  • Supports flexible tag formatting and path customization options to comply with various development environments. You can adjust your output using single quotes --single-quotes, self-closing tags --xhtml, path prefixes --path and path overrides --path-override 📝

  • Supports generating classic web app icons such as favicons --favicon and Windows static tiles --mstile

Install

$ npm install pwa-asset-generator

One-off execution

$ npx pwa-asset-generator

Read more about npx here.

Usage

$ pwa-asset-generator --help

  Usage
    $ pwa-asset-generator [source-file] [output-folder]

    The assets will be saved to the folder where the command is executed if no output-folder provided.

  Options
    -b --background             Page background to use when image source is provided: css value  [default: transparent]
    -o --opaque                 Shows white as canvas background and generates images without transparency  [default: true]
    -p --padding                Padding to use when image source provided: css value  [default: "10%"]
    -s --scrape                 Scraping Apple Human Interface guidelines to fetch splash screen specs  [default: true]
    -m --manifest               Web app manifest file path to automatically update manifest file with the generated icons
    -i --index                  Index HTML file path to automatically put splash screen and icon meta tags in
    -a --path                   Path prefix to prepend for href links generated for meta tags
    -v --path-override          Override the path of images used in href/src tags of manifest and HTML files
    -t --type                   Image type: png|jpg  [default: jpg - with the exception of manifest files]
    -q --quality                Image quality: 0...100 (Only for JPG)  [default: 70]
    -h --splash-only            Only generate splash screens  [default: false]
    -c --icon-only              Only generate icons  [default: false]
    -f --favicon                Generate favicon image and HTML meta tag  [default: false]
    -w --mstile                 Generate Windows static tile icons and HTML meta tags  [default: false]
    -e --maskable               Declare icons in manifest file as maskable icons  [default: true]
    -l --landscape-only         Only generate landscape splash screens  [default: false]
    -r --portrait-only          Only generate portrait splash screens  [default: false]
    -d --dark-mode              Generate iOS splash screen meta with (prefers-color-scheme: dark) media attr  [default: false]
    -u --single-quotes          Generate HTML meta tags with single quotes  [default: false]
    -x --xhtml                  Generate HTML meta tags by self-closing the tags  [default: false]
    -g --log                    Logs the steps of the library process  [default: true]
    -n --no-sandbox             Disable sandbox on bundled Chromium on Linux platforms - not recommended  [default: false]

  Examples
    $ pwa-asset-generator logo.html
    $ pwa-asset-generator logo.svg -i ./index.html -m ./manifest.json
    $ pwa-asset-generator https://your-cdn-server.com/assets/logo.png ./ -t jpg -q 90 --splash-only --portrait-only
    $ pwa-asset-generator logo.svg ./assets --splash-only --xhtml --single-quotes
    $ pwa-asset-generator logo.svg ./assets --scrape false --icon-only --path "%PUBLIC_URL%"
    $ pwa-asset-generator logo.svg ./assets --icon-only --favicon --opaque false --maskable false --type png
    $ pwa-asset-generator logo.svg ./assets --dark-mode --background dimgrey --splash-only --quality 80
    $ pwa-asset-generator logo.svg ./assets --padding "calc(50vh - 5%) calc(50vw - 10%)" --path-override "./your-custom-image-folder-path"
    $ pwa-asset-generator https://elegantapp.github.io/pwa-asset-generator/static/logo.png ./temp -p "15%" -b "linear-gradient(to right, #fa709a 0%, #fee140 100%)"
    $ pwa-asset-generator https://elegantapp.github.io/pwa-asset-generator/static/blm.png ./blm -p "15%" -b "linear-gradient(to right top, #d16ba5, #c777b9, #ba83ca, #aa8fd8, #9a9ae1, #8aa7ec, #79b3f4, #69bff8, #52cffe, #41dfff, #46eefa, #5ffbf1)"

  Flag examples
    --background "rgba(255, 255, 255, .5)"
    --opaque false
    --padding "10px"
    --scrape false
    --manifest ./src/manifest.json
    --index ./src/index.html
    --path "%PUBLIC_URL%"
    --path-override "./your-custom-image-folder-path"
    --type jpg
    --quality 80
    --splash-only
    --icon-only
    --favicon
    --mstile
    --maskable false
    --landscape-only
    --portrait-only
    --dark-mode
    --single-quotes
    --xhtml
    --log false

Module

pwa-asset-generator is not only a CLI. It's a CLI wrapper around a JavaScript module. It's possible to access the underlying API of the library as it's described in below example;

const pwaAssetGenerator = require('pwa-asset-generator');

// Generate images over a module function call, instead of using CLI commands
(async () => {
  const { savedImages, htmlMeta, manifestJsonContent } = await pwaAssetGenerator.generateImages(
    'https://elegantapp.github.io/pwa-asset-generator/static/logo.png',
    './temp',
    {
      scrape: false,
      background: "linear-gradient(to right, #fa709a 0%, #fee140 100%)",
      splashOnly: true,
      portraitOnly: true,
      log: false
    });
})();

// Access to static data for Apple Device specs that are used for generating launch images
const appleDeviceSpecsForLaunchImages = pwaAssetGenerator.appleDeviceSpecsForLaunchImages;

FAQ

What kind of image input should I use with this library? What are the safe margins for a logo?

Any image format that a Chrome browser can render within an <img> HTML tag, is a compatible image input. It can be an icon, an SVG file, a JPEG or PNG logo, even a WebP image.

pwa-asset-generator uses a Chrome tab as an art board. Your input image is being scaled to fit the viewport of the target device resolution while generating splash screens. Since your input image is being scaled for generating splash screens, it's best advised to use a vector image - like an SVG file as an input.

There's no particular safe margin requirement as 10% padding is added around your image input by default with CSS. That being said, you can customize the padding as it's described in the next answer. The library uses a similar approach while generating icons too, with the same default padding 10% around the image input. See it in action here at this tweet to understand the concept.

How can I make an image smaller or larger relative to the background?

The default value for the padding surrounding the image is 10%. But it's just a css padding value that you can configure and override yourself with -p --padding option.

  1. You can use a more advanced padding value based on your taste and goal;

    Larger logo: --padding "calc(50vh - 20%) calc(50vw - 40%)"

    Smaller logo: --padding "calc(50vh - 5%) calc(50vw - 10%)"

  2. You can create your own html input file which uses css media queries and provides different padding options based on breakpoints: https://material.io/design/layout/responsive-layout-grid.html#breakpoints

How can I generate a PNG image with a transparency?

Although the default background color is transparent, there's another option that you need to use for generating transparent images: opaque.

You need to run your CLI command with --opaque false option in order to get the transparency; pwa-asset-generator logo.svg --opaque false --type png.

This might be confusing for some, but it's necessary to support the use of background values with alpha channels.

How can I generate a transparent favicon, and app icons with opaque background?

Default behaviour of the library is to generate a favicon along with app icons. So, it's not possible to generate one without other.

However, you can use this workaround to work with this edge case:

  • First, generate a favicon with --opaque false --icon-only --favicon --type png options.
  • Then, overwrite app icons with --background "#FFF" --icon-only options.

How can I generate both dark mode and light mode splash screen images?

You need to execute two consequent commands in order to generate both dark mode and light mode splash screens for you PWA running on iOS.

Here's a pair of example commands that can be used for generating both modes;

npx pwa-asset-generator light-logo.svg ./assets --dark-mode --background dimgrey --splash-only --type jpeg --quality 80 --index ./src/app/index.html
npx pwa-asset-generator dark-logo.svg ./assets --background lightgray --splash-only --type jpeg --quality 80 --index ./src/app/index.html

As you can see from the demonstration of dark mode splash screens at this tweet, users have to re-add a PWA to the home screen in order to react to a system setting change.

An existing PWA on a home screen will not be able to recognize changed system settings for it's launch image. This is a limitation on iOS.

Are deprecated device-width and device-height media queries necessary?

Even though they're deprecated, device-width and device-height media queries are still being used by iOS to declare splash screen images for web apps added to a home screen.

When it's an exact match with device's resolution, iOS displays the splash screen as a launch image on bookmarks / PWAs added to a home screen.

How can I use JSX syntax to generate the meta tags?

If you don't have HTML files in your project, and have a JSX/TSX files instead, you can either use --xhtml option or self-generate the meta tags.

The --xhtml option allows you to generate the required meta tags with self-closing them - < />. This will allow copying generated tags directly to a JSX/TSX file.

Alternatively, you can use static data that this library exports to generate the required meta tags! pwa-asset-generator exposes the static Apple device specification data via it's module API. Here's an example JSX snippet;

import { appleDeviceSpecsForLaunchImages } from 'pwa-asset-generator';

render() {
  return (
    <>
      {appleDeviceSpecsForLaunchImages.map((spec) => {
        return (
          <>
            <link
              key={`apple-splash-${spec.portrait.width}-${spec.portrait.height}`}
              rel="apple-touch-startup-image"
              href={`apple-splash-${spec.portrait.width}-${spec.portrait.height}.png`}
              media={`(device-width: ${spec.portrait.width /
                spec.scaleFactor}px) and (device-height: ${spec.portrait
                .height /
                spec.scaleFactor}px) and (-webkit-device-pixel-ratio: ${
                spec.scaleFactor
              }) and (orientation: portrait)`}
            />
            <link
              key={`apple-splash-${spec.portrait.width}-${spec.portrait.height}`}
              rel="apple-touch-startup-image"
              href={`apple-splash-${spec.portrait.width}-${spec.portrait.height}.png`}
              media={`(device-width: ${spec.portrait.height /
                spec.scaleFactor}px) and (device-height: ${spec.portrait
                .width /
                spec.scaleFactor}px) and (-webkit-device-pixel-ratio: ${
                spec.scaleFactor
              }) and (orientation: landscape)`}
            />
          </>
        );
      })}
    </>
  );
}

My index.html file's format has been changed after an automated update. Is there any way to re-format it?

pwa-asset-generator uses pretty for formatting your index.html file with a simple, opinionated output.

A recommended way to maintain the same format for your index.html file would be using Prettier and adding the following script to your project's package.json file.

"format:index": "prettier \"index.html\" --write"

Executing npm run format:index after using pwa-asset-generator assures the same format for your HTML file.

When generating PNG images, there's no compression settings. Is there a way to introduce compression for PNG files?

pwa-asset-generator depends on Puppeteer, and it's screenshot API for image generation. Puppeteer doesn't provide compression settings for PNG files for the time being.

However, you can use one of the lossless / lossy compression libraries - like pngquant to compress the generated PNG images.

Running the CLI command on CI server causes Puppeteer error: "Running as root without --no-sandbox is not supported". How can I disable sandboxing?

In case of getting "No usable sandbox!" error on Linux, you need to enable system sandboxing.

PAG provides users the --no-sandbox option to tackle this issue. Note that there are limitations for this option; it can only be used on Linux platforms and HTML inputs are disabled for security purposes.

You saved me hours of work with pwa-asset-generator. How can I support this project?

We're glad you enjoy PWA Asset Generator, and it saved you your precious time. Become one of the backers and help us maintain this project!

pwa-asset-generator's People

Contributors

atjn avatar charlesgrimont avatar chimurai avatar dependabot-preview[bot] avatar dependabot[bot] avatar leonelngande avatar ofcyln avatar onderceylan avatar sbannigan avatar semantic-release-bot avatar sneas avatar willheslam avatar workeffortwaste avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pwa-asset-generator's Issues

Prevent reformatting index.html

When index.html is provided as an output, cheerio reformats the code style on the file while adding the html tags. It also creates empty new lines when modification happens on already processed index.html file.

Add --type and --quality flags

Currently app only generates images in png format. Adding --type flag will make it possible to generate jpg output with compression options provided by --quality flag. This is important for reducing sizes of large launch images with rich background.

Expose private API and add typings.d.ts

Currently it's not possible to use underlying API of the library other than using it via executable binary. Exposing private API that binary uses, will make it possible for users to use it in their node projects.

Exporting typings.d.ts will introduce a living documentation for the API.

Add single-quotes option for generated meta and link tags

Low code platforms like Outsystems doesn't allow adding double quoted html in the system. Adding an optional single-quotes option will make things easier for platforms with such limitation and for people with single quote taste.

Add dark mode support for iOS

I just found out that we can actually use dark mode media attributes (prefers-color-scheme: dark) to differentiate splash screens on iOS 13, based on user preference. The same media attribute doesn't have any affect on icons, even though it's the same web element and same media attr.

Light mode (default):
<link rel="apple-touch-startup-image" href="light/apple-splash-2048-2732.jpeg" media="(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">

Dark mode:
<link rel="apple-touch-startup-image" href="dark/apple-splash-2048-2732.jpeg" media="(prefers-color-scheme: dark) and (device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">

It has to be declared in that order, tags with no prefers-color-scheme media attr declared first and dark ones declared after.

Utilize util.promisify()

As node engine req has been increased to >=8.16.0 with pptr v2 upgrade, we can use node's util.promisify()method on file service.

Transparent background does not work

Describe the bug
The docs says that transparent background is default but this is not happening

To Reproduce
Steps to reproduce the behavior:

  1. Execute cli command npx pwa-asset-generator https://icon-library.net/images/img_566996.png
  2. Open generated images
  3. See error

Expected behavior
Images with transparent background.

System (please complete the following information):

  • OS: windows 10
  • node version 12.13.0
  • npm version 6.12.0
  • cli version 2.1.1

Screenshots
Webstorm show if the background is transparent (which is not in this case)
image

add favicon only flags

Here is the situation,
I want to generate a transparent favicon, and white background for splash and icon, but there is no such option.

when I set {favicon: true}, the program automatically generate icon & splash for me

Thus here is my workaround, first I generate favicon with { opaque: false, iconOnly: true, favicon: true } and then overwrite it with {background:"#FFFFFF", favicon:false} option.

I wonder if we can add faviconOnly flag.

Extend cli test suite with file saving scenarios

When any of index.html or manifest.json file is provided to a cli, meta information is saved on them. Current functionality of that is not tested in any scenarios. We need to extend cli.test.js file by adding those test to cover existing functionality.

npm detects vulnerability

Describe the bug
When running npm audit, a high severity vulnerability is detected

To Reproduce
Steps to reproduce the behavior:

  1. Execute cli command npm audit

Expected behavior
No vulnerability gets flagged

System (please complete the following information):

  • macOS Catalina
  • node version v10.16.0
  • npm version 6.9.0
  • cli version 1.1.6

Screenshots
Screen Shot 2019-10-19 at 11 23 37 PM

Additional context
None

Upgrade to pptr 2 to and generate images on single chromium instance

Before puppeteer v2, we had to initialize a new chromium instance to take a screenshot of a different window size. New schreenshot API can change the viewport properly so we just need to create a new tab, no need to create a new instance.

This change will make the lib much less cpu and memory intensive.

Release 1.3.0 breaks relative source file locations

Describe the bug
After upgrading to 1.3.0, "npx pwa-asset-generator logo.svg" stopped working. The output files all had the typical "missing image" that you've scene in browsers before. I haven't fully diagnosed the problem, but it still works with absolute urls and with absolute paths for local files, just not relative ones.

To Reproduce
Steps to reproduce the behavior:

  1. create a new directory, copy some image to that directory
  2. run npx pwa-asset-generator <your image file>
  3. open manifest-icon-512.png

Expected behavior
manifest-icon-512.png should contain my image (but it doesn't)

System (please complete the following information):

  • OS: macOS high sierra
  • node version v11.10.0
  • npm version 6.10.3
  • cli version 1.3.0 (note, it works fine in 1.2.0)

Screenshots
manifest-icon-512

Create a gif showing the cli usage and output

  • Creating a gif that shows apps usage and output
  • Putting it as a static resource on repository
  • Embedding it to documentation

will attract more users and it will help on libraries promotion.

Avoid shell html creation in module folder

Currently, the library saves a shell html file on the fly to the libraries /static folder each time you execute an image generation. Although it's not a problem for most users, this design causes some issues where there are ownership problems with the installed module on users OS.

We can get over this issue by using following page navigation via puppeteer;
await page.goto(data:text/html,${html});

Question: landscape

Hi!
What about the next screenshot? :

Screenshot_20191007-000043_Chrome

Does the generator currently cover all cases or any is missing?

Add maskable icons for Android

Is your feature request related to a problem? Please describe.
As W3C specs on manifest file has been extended with the new purpose field and maskable icons, it's a good idea to add maskable icons feature to pwa-asset-generator.

Describe the solution you'd like
We need to add a new flag --maskable which will be respected when icons are generated. When flag is provided, the manifest file meta has to be aligned with specs here: https://www.w3.org/TR/appmanifest/#icon-masks

A more detailed article on maskable icons is here: https://css-tricks.com/maskable-icons-android-adaptive-icons-for-your-pwa/

Nice to have: if we can detect the safe zone of a custom html input and warn if it exceeds the zone. Intersection Observer API might be handy for that.

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Splash Screen not showing in landscape on iOS 12.4

First of all: awesome package. Such a good idea!

In order for me to get splash screens to work on (2) separate iOS devices (iPhone XS Max + iPad mini) both running iOS 12.4, I had to add and (orientation: landscape) as well as maintaining the device-width and device-height dimensions as its portrait counterpart.

For instance, this got landscape working on my iPhone XS Max:

<link
  rel="apple-touch-startup-image"
  href="/static/images/splash/apple-splash-1242-2688.png"
  media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)"
/>
<link
  rel="apple-touch-startup-image"
  href="/static/images/splash/apple-splash-2688-1242.png"
  media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)"
/>

This is what was generated by this package (only portrait works):

<link rel="apple-touch-startup-image" href="apple-splash-1242-2688.png" media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3)">
<link rel="apple-touch-startup-image" href="apple-splash-2688-1242.png" media="(device-width: 896px) and (device-height: 414px) and (-webkit-device-pixel-ratio: 3)">

You would think that the way landscape meta tags are currently generated would be fine... Thanks Apple

Create output folder if it doesn't exist

Currently app throws an error when output directory does not exist or it's not writable. If doesn't exist, app should create the folder on behalf of the user.

Path prefix encoding in index.html

Describe the bug
Path prefix are html encoded.
I'm trying to use this for a VueJS app. Index.html file is a template that will be augmented during the build process.

Typically it contains some templating for environment variables

  <link rel="icon" href="<%= BASE_URL %>favicon.ico">

This tool is encoding any path, can we disable this behavior ?

To Reproduce
Steps to reproduce the behavior:

  1. Execute cli command pwa-asset-generator -i ./public/index.html -a "<%= BASE_URL %>" ./public/img/assets/logo.svg ./public/assets
  2. Open 'index.html'
  3. <> are encoded
<link rel="icon" href="&lt;%= BASE_URL %&gt;favicon.ico">

Expected behavior
A clear and concise description of what you expected to happen.

System (please complete the following information):

  • cli version 2.0.0

Add --splash and --icon flags

Adding optional --splash and --icon flags will make it possible to only generate images for a specific set. This will make it possible to generate splash screen images and icons with different options per each set.

Add --portrait and --landscape flags

Currently app generates splash screens on both portrait and landscape format. Some PWAs are constrained to be launched in one of portrait or landscape. So, adding this options will make it possible to only generate splash screen images for a specific orientation.

Add option to provide path prefix to generated href links

Would be nice to be able to prepend a path to the href links generated in index.html.

In my case, I'm using pwa-asset-generator in the context of a create-react-app application and my links need to look like this: <link rel="apple-touch-icon" sizes="180x180" href="%PUBLIC_URL%/apple-icon-180.png">

Deprecated media feature “device-width”

After updating the source and validating, multiple error are shown.

line 47: Bad value “(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)” for attribute “media” on element “link”: Deprecated media feature “device-width”. For guidance, see the Deprecated Media Features section in the current Media Queries specification.

And this is that line:

<link rel="apple-touch-startup-image" href="http://127.0.0.1/compro/public/pwa/apple-splash-2048-2732.png" media="(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">

Thanks.

Assets are not created in current folder if output param is not provided

Readme tells that "The assets will be saved to the folder where the command is executed if no output-folder provided". To check this point, I'm executing the example from Readme without output folder provided like that:
pwa-asset-generator https://cdn.freebiesupply.com/logos/large/2x/amazon-icon-logo-png-transparent.png -p "20%" -b "linear-gradient(to top, #fad0c4 0%, #ffd1ff 100%)"

It gives me an error:
cli TypeError: path must be a string or Buffer

Incorrect file paths generated on Windows

Describe the bug
On Windows, the asset paths generated have double back-slashes (sometimes three) at the first directory level. This causes cli.test.js to fail, also user has to manually correct the asset paths generated.

To Reproduce
Steps to reproduce the behavior:

  1. Execute cli command git clone https://github.com/onderceylan/pwa-asset-generator.git
  2. cd to project root and execute cli command: npm run jest
  3. See error

Expected behavior
cli.test.js should pass

System (please complete the following information):

  • OS: windows 10
  • node version: v10.15.3
  • npm version: 6.11.2
  • cli version: 1.1.6

Screenshots
image

Migrate code to TypeScript

Migrating code to TypeScript will make the contribution easier for the project.

It will also enable us to deliver a compiled code which will help project to be used with earlier versions of node. Due to ES2015 features used in the code, node engine is restricted for versions <8.3.0

Chrome launcher does not exit properly on connection error

In case of connect ECONNREFUSED error, chrome launcher instances doesn't get killed. This creates memory issues and introduces SPOF for the lib.

A preferred solution for this is to treat system browser initialization differently and let launcher handle the process management on error.

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.