All Projects → brunocodutra → Webapp Webpack Plugin

brunocodutra / Webapp Webpack Plugin

Licence: mit
[DEPRECATED] use favicons-webpack-plugin instead

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Webapp Webpack Plugin

Webpack Pwa Manifest
Progressive Web App Manifest Generator for Webpack, with auto icon resizing and fingerprinting support.
Stars: ✭ 447 (+251.97%)
Mutual labels:  webpack, manifest, plugin, pwa
Pwa Asset Generator
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.
Stars: ✭ 1,787 (+1307.09%)
Mutual labels:  manifest, icon, favicon, pwa
Offline Plugin
Offline plugin (ServiceWorker, AppCache) for webpack (https://webpack.js.org/)
Stars: ✭ 4,444 (+3399.21%)
Mutual labels:  webpack, plugin, pwa
Prestashop
Free PWA & SPA for PrestaShop
Stars: ✭ 59 (-53.54%)
Mutual labels:  webpack, pwa, webapp
Learning Pwa
📱some samples and blogs about how to start with your first PWA
Stars: ✭ 162 (+27.56%)
Mutual labels:  manifest, pwa, webapp
Vue Pwa Asset Generator
PWA asset generator perfect with VueJS framework (but useful for all PWA!)
Stars: ✭ 97 (-23.62%)
Mutual labels:  manifest, icon, pwa
Serverless Plugin Webpack
Serverless Plugin Webpack
Stars: ✭ 72 (-43.31%)
Mutual labels:  webpack, plugin
Pwa Badge
Badging for PWA app icons, Like Native Apps
Stars: ✭ 78 (-38.58%)
Mutual labels:  icon, pwa
Gradle Util Plugins
Fix for windows gradle long classpath issue. Fixes JavaExec tasks that error out with message "CreateProcess error=206, The filename or extension is too long"
Stars: ✭ 87 (-31.5%)
Mutual labels:  manifest, plugin
Absolute
Absolute is a web-based O2O(Online to Offline) platform like Siren-Order for Starbucks. We are focused on creating the platform that is portable, cheaper, easier, decentralized and appless.
Stars: ✭ 96 (-24.41%)
Mutual labels:  pwa, webapp
Node Express Typescript Boilerplate
A boilerplate for developing web apps with Node.js, Express.js & TypeScript. Demonstrates helpful recipes in 8 steps in individual branches.
Stars: ✭ 60 (-52.76%)
Mutual labels:  webpack, webapp
Award
⚙基于react的服务端渲染框架
Stars: ✭ 91 (-28.35%)
Mutual labels:  webpack, plugin
Fork Ts Checker Webpack Plugin
Webpack plugin that runs typescript type checker on a separate process.
Stars: ✭ 1,343 (+957.48%)
Mutual labels:  webpack, plugin
Starter React Flux
Generate your React PWA project with TypeScript or JavaScript
Stars: ✭ 65 (-48.82%)
Mutual labels:  webpack, pwa
Mt Music Player
Web music player
Stars: ✭ 63 (-50.39%)
Mutual labels:  pwa, webapp
Inline Chunk Manifest Html Webpack Plugin
Extension plugin for html-webpack-plugin to inline webpack's chunk manifest. Default inlines in head tag.
Stars: ✭ 83 (-34.65%)
Mutual labels:  webpack, manifest
Jpg Glitch
glitch images with jpg encoding
Stars: ✭ 1,120 (+781.89%)
Mutual labels:  pwa, webapp
Cypress Webpack Preprocessor
Cypress preprocessor for bundling JavaScript via webpack
Stars: ✭ 93 (-26.77%)
Mutual labels:  webpack, plugin
Wordless
All the power of Pug, Sass, Coffeescript and WebPack in your WordPress theme. Stop writing themes like it's 1998.
Stars: ✭ 1,374 (+981.89%)
Mutual labels:  webpack, plugin
Sysmon
A B/S mode system monitor for linux (demo http://199.247.1.240:2048)
Stars: ✭ 110 (-13.39%)
Mutual labels:  pwa, webapp

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="167x167" href="/assets/apple-touch-icon-167x167.png">
<link rel="apple-touch-icon" sizes="180x180" href="/assets/apple-touch-icon-180x180.png">
<link rel="apple-touch-icon" sizes="1024x1024" href="/assets/apple-touch-icon-1024x1024.png">
<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: 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: 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: portrait) and (-webkit-device-pixel-ratio: 2)" href="/assets/apple-touch-startup-image-1536x2008.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="228x228" href="/assets/coast-228x228.png">
<link rel="manifest" href="/assets/manifest.json">
<link rel="shortcut icon" href="/assets/favicon.ico">
<link rel="yandex-tableau-widget" href="/assets/yandex-browser-manifest.json">
<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">
<meta name="application-name">
<meta name="mobile-web-app-capable" content="yes">
<meta name="msapplication-TileColor" content="#fff">
<meta name="msapplication-TileImage" content="/assets/mstile-144x144.png">
<meta name="msapplication-config" content="/assets/browserconfig.xml">
<meta name="theme-color" content="#fff">

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',
    // Enable caching and optionally specify the path to store cached data
    // Note: disabling caching may increase build times considerably
    cache: true,
    // Override the publicPath option usually read from webpack configuration
    publicPath: '/static',
    // The directory to output the assets relative to the webpack output dir.
    // Relative string paths are allowed here ie '../public/static'. If this
    // option is not set, `prefix` is used.
    outputPath: '/public/static',
    // Prefix path for generated assets
    prefix: 'assets/',
    // Inject html links/metadata (requires html-webpack-plugin).
    // This option accepts arguments of different types:
    //  * boolean
    //    `false`: disables injection
    //    `true`: enables injection if that is not disabled in html-webpack-plugin
    //  * string
    //    `'force'`: enables injection even if that is disabled in html-webpack-plugin
    //  * function
    //    any predicate that takes an instance of html-webpack-plugin and returns either
    //    `true` or `false` to control the injection of html metadata for the html files
    //    generated by this instance.
    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.

Examples

Basic

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
      }
    }
  })
]

Handling Multiple HTML Files

const WebappWebpackPlugin = require('webapp-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { basename } = require('path')

...

plugins: [
    new HtmlWebpackPlugin({
        template: 'a.html.tmpl',
        filename: 'a.html',
    }),
    new HtmlWebpackPlugin({
        template: 'b.html.tmpl',
        filename: 'b.html',
    }),
    new WebappWebpackPlugin({
        logo: 'logo.svg',
        inject: htmlPlugin => 
          basename(htmlPlugin.options.filename) === 'a.html',
    }),
],

Hooks

To allow other plugins to intercept and customise assets before they are emitted, the following hooks may be tapped

webappWebpackPluginBeforeEmit

AsyncSeriesWaterfallHook

Example implementation:

  new class {
    apply(compiler) {
      compiler.hooks.make.tapAsync("A", (compilation, callback) => {
        compilation.hooks.webappWebpackPluginBeforeEmit.tapAsync("B", (result, callback) => {
          // The result of favicons library can be modified here
          // and it will be returned to WebApp Plugin to be emitted.
          // Add your custom functions below
          console.log(result);
          // Return the custom result
          return callback(null, result);
        });
        return callback();
      })
    }
  }

Rule

A Webpack loader rule is also provided to make the generated HTML tags available to your JS app.

const plugin = new WebappWebpackPlugin({ logo: '/path/to/logo.png' });

...

plugins: [
  plugin
]
module: {
  rules: [
    plugin.rule()
  ],
}
// now inside Webpack bundle
// you can require logo path
// and get an array of strings with html tags
const favicons = require( '/path/to/logo.png' );

Note: logo must be an absolute path for rule to work.

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].