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

If a relative path is used for icons path, it is transformed to an absolute path #449

Open
andsouto opened this issue Jan 19, 2024 · 3 comments

Comments

@andsouto
Copy link

I am using as configuration a relative value for path property:

	const configuration = {
		path: 'assets/icons',
		// rest of options
	}

But the generated manifest.webmanifest adds an initial /. e.g.:

    {
      "src": "/assets/icons/android-chrome-36x36.png",
      "sizes": "36x36",
      "type": "image/png",
      "purpose": "any"
    },

Am I missing something or that / shouldn't be added? According to the specification if a relative path is used it is relative to the location of the webmanifest.

@andy128k
Copy link
Collaborator

path configuration is an absolute path to an icons directory. In that regard assets/icons and /assets/icons are equivalent.

@andsouto
Copy link
Author

You are right, I think I was mixing things...

But the problem is the generated manifest is always generated using an absolute path and there is no way to use a relative path. And a relative path makes sense as it is interpreted as relative to the manifest.webmanifest location. If the web app is deployed in a subpath and not in the / of an origin relative paths work but absolute paths don't. And if deployed in / both work exactly the same way.

I'm fixing the problem doing this before writing the webmanifest to distk:

			if (file.name === 'manifest.webmanifest') {
				const contents = file.contents.replaceAll('/assets/icons/', 'assets/icons/');
				return fs.writeFile(`${path}/${file.name}`, contents);
			}

But I think it should be a cleaner way of doing this just by configuration.

@andy128k
Copy link
Collaborator

Things are a bit backwards here. A Manifest file is secondary to icons. Historically the library was designed around icons and whatever else (e.g. manifests) were "extra files to generate".

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

No branches or pull requests

2 participants