Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pwa.manifest.metaVariables overrides my preferred settings in index.template.html #6718

Closed
tohagan opened this issue Apr 1, 2020 · 3 comments

Comments

@tohagan
Copy link
Contributor

tohagan commented Apr 1, 2020

Describe the bug

I'm needing to use an alternative to Icon Genie that emits different icon file names and settings that I'm wanting to configure in index.template.html. However Quasar's PWA plugin is overriding my settings with code emitted into the final index.html.

Expected that setting pwa.manifest.metaVariables to null or {} would remove the emitted code.
However it's just merged with values that restore the defaults.

To Reproduce
Steps to reproduce the behavior:
$ quasar create myapp; cd myapp
$ quasar mode add pwa
$ quasar build -m pwa
$ tr '>' '\012' < dist/pwa/index.html # to view emitted code with line breaks

Observe that the following lines are emitted in index.html that I'd wish to suppress by setting pwa.manifest.metaVariables to null or {}.

<link rel=manifest href=manifest.json
<meta name=theme-color content=#ffe0e0
<meta name=apple-mobile-web-app-capable content=yes
<meta name=apple-mobile-web-app-status-bar-style content=default
<meta name=apple-mobile-web-app-title content="My App"
<link rel=apple-touch-icon href=statics/icons/apple-icon-120x120.png
<link rel=apple-touch-icon sizes=180x180 href=statics/icons/apple-icon-180x180.png
<link rel=apple-touch-icon sizes=152x152 href=statics/icons/apple-icon-152x152.png
<link rel=apple-touch-icon sizes=167x167 href=statics/icons/apple-icon-167x167.png
<link rel=mask-icon href=statics/icons/safari-pinned-tab.svg color=#ffe0e0
<meta name=msapplication-TileImage content=statics/icons/ms-icon-144x144.png
<meta name=msapplication-TileColor content=#000000

Observe that manifest.json also contains metaVariables that AFAIK does not belong in a manifest file (probably does no harm).

Expected behavior

I need a way to remove all of the emitted lines in index.html shown above so I can manually configure them in index.template.html. FYI ... I'll also be using a different manifest file emitted by the other icon generator.

Additional context

@tohagan
Copy link
Contributor Author

tohagan commented Apr 1, 2020

Arguably a feature request rather than a bug.

@tohagan tohagan changed the title PWA icons/manifest overrides my index.html settings pwa.manifest.metaVariables overrides my preferred settings in index.template.html Apr 1, 2020
@rstoenescu
Copy link
Member

Extract from docs when @quasar/app v1.6.2 will be released:

pwa: {
  // workboxPluginMode: 'InjectManifest',
  // workboxOptions: {},
  manifest: {
    // ...
  },

  // Use this OR metaVariablesFn, but not both;
  // variables used to inject specific PWA
  // meta tags (below are default values);
  metaVariables: {
    appleMobileWebAppCapable: 'yes',
    appleMobileWebAppStatusBarStyle: 'default',
    appleTouchIcon120: 'statics/icons/apple-icon-120x120.png',
    appleTouchIcon180: 'statics/icons/apple-icon-180x180.png',
    appleTouchIcon152: 'statics/icons/apple-icon-152x152.png',
    appleTouchIcon167: 'statics/icons/apple-icon-167x167.png',
    appleSafariPinnedTab: 'statics/icons/safari-pinned-tab.svg',
    msapplicationTileImage: 'statics/icons/ms-icon-144x144.png',
    msapplicationTileColor: '#000000'
  },

  // (@quasar/app v1.6.2+)
  // Optional, overrides metaVariables above;
  // Use this OR metaVariables, but not both;
  metaVariablesFn (manifest) {
    // ...
    return [
      {
        // this entry will generate:
        // <meta name="theme-color" content="ff0">

        tagName: 'meta',
        attributes: {
          name: 'theme-color',
          content: '#ff0'
        }
      },

      {
        // this entry will generate:
        // <link rel="apple-touch-icon" sizes="180x180" href="statics/icon-180.png">

        tagName: 'link',
        attributes: {
          rel: 'apple-touch-icon',
          sizes: '180x180',
          href: 'statics/icon-180.png'
        },
        closeTag: false // this is optional;
                        // specifies if tag also needs an explicit closing tag;
                        // it's Boolean false by default
      }
    ]
  }
}

Starting with @quasar/app v1.6.2+, you can use an alternative to metaVariables: metaVariablesFn(manifest) which can return an Array of Objects (see their form in the code above). Should you configure this function to not return an Array or to return an empty Array, then Quasar App CLI will understand not to add any tags -- so you can manually add your custom tags directly in /src/index.template.html.

@tohagan
Copy link
Contributor Author

tohagan commented Apr 4, 2020

Thank you! I'm a bit tight on cash like the rest of the world but I could walk away from this issue with out starting sponsorship. Hoping I can increase the amount one day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants