Coder Social home page Coder Social logo

web-app-manifest-loader's Introduction

Build Status Coverage Status npm

web-app-manifest-loader

Load images referenced in the icons and splash_screens fields in your Web App Manifest using webpack.

$ npm install --save-dev web-app-manifest-loader

Usage

Documentation: Using loaders

In your webpack config:

module: {
  loaders: [
    {
      test: /manifest.json$/,
      loader: 'file-loader?name=manifest.json!web-app-manifest-loader'
    }
  ]
}

Note that this example also uses file-loader.

Then, require the manifest in your application code:

require('./manifest.json');

This allows you to provide image paths in the standard webpack format inside your manifest:

{
  "name": "Hello World",
  ...
  "splash_screens": [
    {
      "src": "./images/splash-hi.png",
      "sizes": "2560x1440",
      "type": "image/png"
    },
    ...
  ],
  "icons": [
    {
      "src": "./images/icon-hi.png",
      "sizes": "512x512",
      "type": "image/png"
    },
    ...
  ]
}

License

MIT License

web-app-manifest-loader's People

Contributors

markdalgleish 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

Watchers

 avatar  avatar

web-app-manifest-loader's Issues

Automatically insert link to head

Currently I have to insert link manually with both file-loader and this one:

import manifest from './manifest.json';

<Helmet>
          <link rel="manifest" href={manifest} />
</Helmet>

It should behave like style-loader, which automatically insert link to <head>. So we can leverage modules like CommonsChunkPlugin etc...

Wrong relative path

I added the loader like the following:

{
     test: /manifest.json$/,
     loader: 'file-loader?name=static/[name].[hash].[ext]!web-app-manifest-loader'
}

I required the manifest require('./manifest.json') and got a manifest like this:

{
  "name": "Web Application Manifest Sample",
  "icons": [
    {
      "src": "static/48.582dae785db93a86476fce708f6d4965.png",
      "sizes": "36x36",
      "type": "image/png",
      "density": 0.75
    }
...

It is embedded in the html like the following:

<link rel="manifest" href="static/manifest.c9c8aa597bfdf6603f400152c60c27e4.json">

According to MDN, relative urls should be relative to the manifest, quoting

Quoting MDN:

The path to the image file. If src is a relative URL, the base URL will be the URL of the manifest.

This seems like a bug. The JSON should look like this:

{
  "name": "Web Application Manifest Sample",
  "icons": [
    {
      "src": "48.582dae785db93a86476fce708f6d4965.png",
      "sizes": "36x36",
      "type": "image/png",
      "density": 0.75
    }
...

FaviconsWebpackPlugin

Hi,

This loader should be able to get its icon files from the FaviconWebpackPlugin.

Or should the manifest webpack plugin also have an option to output a web manifest?

What do you think?

JSON.parse invalid json

In this try

try { var manifest = JSON.parse(source); } catch (err) { return callback(new Error('Invalid JSON in Web App Manifest')); }

I'm getting the error message Invalid JSON in Web App Manifest

But JSON in my manifest.json is valid

Loaders can't be specified inline

For example, the following won't work:

{
  "icons": [
    "src": "file-loader!./image.png",
    "sizes": "256x256",
    "type": "image/png"
  ]
}

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.