Giter Site home page Giter Site logo

sugarshin / webapp-webpack-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brunocodutra/webapp-webpack-plugin

0.0 3.0 0.0 1.4 MB

Let webpack generate your progressive web app icons for you

Home Page: https://www.npmjs.com/package/webapp-webpack-plugin

License: MIT License

JavaScript 100.00%

webapp-webpack-plugin's Introduction

Webapp Webpack Plugin

npm version Coverage Status Build Status Build status Greenkeeper badge Dependency Status

Leverages on favicons to automatically generate your progressive web app for you.

Originally forked from jantimon/favicons-webpack-plugin
What's new?

Installation

Install the plugin with npm:

$ npm install --save-dev webapp-webpack-plugin

Basic Usage

Add the plugin to your webpack config as follows:

const WebappWebpackPlugin = require('webapp-webpack-plugin')

...

plugins: [
  new WebappWebpackPlugin('/path/to/logo.png') // svg works too!
]

The default configuration will automatically generate webapp manifest files along with 44 different icon formats as appropriate for iOS devices, Android devices, Windows Phone and various desktop browsers out of your single logo.png.

Tip: You might want to fine tune what vendors to support.

A Note on Path Resolution

Under the hood, Webpack resolves the path to logo according to the following rules:

  • If /path/to/logo is absolute, there is nothing to resolve and the path specified is used as is.

  • If ./path/to/logo is relative, it's resolved with respect to Webpack's context, which defaults to process.cwd().

  • If path/to/logo is neither explicitly relative nor absolute, Webpack attempts to resolve it according to resolve.modules, which defaults to modules: ["node_modules"].

HTML Injection

In combination with html-webpack-plugin it will also inject the necessary html for you:

Note: html-webpack-plugin must come before webapp-webpack-plugin in the plugins array.

<link rel="apple-touch-icon" sizes="57x57" href="assets/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="assets/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="assets/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="assets/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="assets/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="assets/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="assets/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="assets/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="assets/apple-touch-icon-180x180.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="webapp-webpack-plugin">
<link rel="manifest" href="assets/manifest.json">
<meta name="mobile-web-app-capable" content="yes">
<meta name="theme-color" content="#fff">
<meta name="application-name" content="webapp-webpack-plugin">
<link rel="icon" type="image/png" sizes="228x228" href="assets/coast-228x228.png">
<link rel="yandex-tableau-widget" href="assets/yandex-browser-manifest.json">
<link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 1)" href="assets/apple-touch-startup-image-320x460.png">
<link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)" href="assets/apple-touch-startup-image-640x920.png">
<link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)" href="assets/apple-touch-startup-image-640x1096.png">
<link rel="apple-touch-startup-image" media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2)" href="assets/apple-touch-startup-image-750x1294.png">
<link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 736px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 3)" href="assets/apple-touch-startup-image-1182x2208.png">
<link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 736px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 3)" href="assets/apple-touch-startup-image-1242x2148.png">
<link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 1)" href="assets/apple-touch-startup-image-748x1024.png">
<link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 1)" href="assets/apple-touch-startup-image-768x1004.png">
<link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2)" href="assets/apple-touch-startup-image-1496x2048.png">
<link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2)" href="assets/apple-touch-startup-image-1536x2008.png">
<meta name="msapplication-TileColor" content="#fff">
<meta name="msapplication-TileImage" content="mstile-144x144.png">
<meta name="msapplication-config" content="browserconfig.xml">
<link rel="icon" type="image/png" sizes="32x32" href="assets/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/favicon-16x16.png">
<link rel="shortcut icon" href="assets/favicon.ico">

https://github.com/brunocodutra/webapp-webpack-plugin/blob/master/test/fixtures/expected/html

Advanced Usage

plugins: [
  new WebappWebpackPlugin({
    // Your source logo (required)
    logo: '/path/to/logo.png',
    // Path to store cached data or false/null to disable caching altogether
    // Note: disabling caching may increase build times considerably
    cache: '.wwp-cache',
    // Prefix for generated assets, might be a folder or just a name prefix
    prefix: 'assets-[hash]/',
    // Inject html links/metadata (requires html-webpack-plugin)
    inject: true,

    // Favicons configuration options (see below)
    favicons: {
      ...
    }
  })
]

To fine tune what icons/metadata is generated, refer to favicons' documentation.

The options specified under favicons: are handed over as is to favicons, except that if appName, appDescription, version, developerName or developerURL are left undefined, they will be automatically inferred respectively from name, description, version, author.name and author.url as defined in the nearest package.json if available. To disable automatically retrieving metadata from package.json, simply set to null the properties you want to omit.

Example:

const WebappWebpackPlugin = require('webapp-webpack-plugin')

...

plugins: [
  new WebappWebpackPlugin({
    logo: '/path/to/logo.png', // svg works too!
    favicons: {
      appName: 'my-app',
      appDescription: 'My awesome App',
      developerName: 'Me',
      developerURL: null, // prevent retrieving from the nearest package.json
      background: '#ddd',
      theme_color: '#333',
      icons: {
        coast: false,
        yandex: false
      }
    }
  })
]

Contribution

You're very welcome to contribute to this project by opening issues and/or pull requests.

Please keep in mind that every change and new feature should be covered by tests.

License

This project is licensed under MIT.

webapp-webpack-plugin's People

Contributors

brunocodutra avatar jantimon avatar greenkeeper[bot] avatar viamin avatar kajyr avatar lucassus avatar numical avatar nicolas-lescop avatar

Watchers

James Cloos avatar Shingo Sato avatar  avatar

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.