wingsuit-designsystem / wingsuit

Twig for Storybook
GNU General Public License v2.0
91 stars 16 forks source link

Feature/pwa preset #175

Closed iuscare closed 3 years ago

iuscare commented 3 years ago

This preset adds the possibility to automatically generate your favicons in multiple formats, as well as your webapp manifest.json. Following props are exposed to be used in the wingsuit.config.yml:

Prop Type Desc
logo {string | default: './source/favicon-src.png'} Path to your source logo. Logo can be either png or svg
prefix {string | default: 'images/favicons/'} Prefix which gets injected into your webapp.html
publicPath {string | default: 'images/favicons/'} Destination of your favicons (will mostly be the same as your prefix)
appName {string | default: 'null'} Your application's name
appDescription {string | default: 'null'} Your application's description
developerName {string | default: 'null'} Your (or your developer's) name
developerURL {string | default: 'null'} Your (or your developer's) URL

Example configuration:

const namespaces = require('./source/default/namespaces');

module.exports = {
  presets: ['@wingsuit-designsystem/preset-pwa'],
  parameters: {
    pwa: {
      // path to source (default: './source/favicon-src.png')
      logo: './source/favicon-src.svg',
      // injected prefix (default: '/images/favicons/')
      prefix: '/img/favicons',
      // destination (default: '/images/favicons/')
      publicPath: '/img/favicons',
      // App Name (default: 'null')
      appName: 'My awesome app',
      // App Description (default: 'null')
      appDescription: 'App developed with the awesome wingsuit package',
      // Developer Name (default: 'null')
      developerName: 'Steve Jobs',
      // Developer URL (default: 'null')
      developerURL: 'https://keytec.de',
    },
  },
  designSystems: {
    default: {
      namespaces,
    },
  },
};

Out of the box the preset will generate multiple formats of your favicons and your manifest.json only when running a production build of drupal. It will look for a favicon-src.png in your source folder. The generated files will be placed into /dist/[app]/images/favicons by default. You have, however, the possibility to modify all of this by using a special pwa object within the paremeters object in your wingsuit.config.js.