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

Relocate manifest.json to ./public/ #4890

Merged
merged 3 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/gatsby-plugin-manifest/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function generateIcons(icons, srcIcon) {
return Promise.map(icons, icon => {
const size = parseInt(icon.sizes.substring(0, icon.sizes.lastIndexOf(`x`)))
const imgPath = `./public/` + icon.src
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you have this use path.join as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KyleAMathews fixed it! 😇


return sharp(srcIcon)
.resize(size)
.toFile(imgPath)
Expand All @@ -22,7 +22,7 @@ exports.onPostBuild = (args, pluginOptions) =>
new Promise(resolve => {
const { icon } = pluginOptions
const manifest = { ...pluginOptions }

// Delete options we won't pass to the manifest.json.
delete manifest.plugins
delete manifest.icon
Expand All @@ -40,8 +40,8 @@ exports.onPostBuild = (args, pluginOptions) =>
fs.mkdirSync(iconPath)
}

fs.writeFileSync(`${iconPath}/manifest.json`, JSON.stringify(manifest))
fs.writeFileSync(`./public/manifest.json`, JSON.stringify(manifest))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moonmeister what was iconPath supposed to be for? It looks like everything is in the root of the public folder anyways?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iconPath calculated from the the icons array. It's important for making sure icons and (the way I wrote it) the manifest into the path specified as the icons path. Thus if someone manually supplies an icons array with a path different then what I've used in the default array everything gets put to that correct path. If we're moving manifest out of the folder it it does not affect the manifest.


// Only auto-generate icons if a src icon is defined.
if (icon !== undefined) {
generateIcons(manifest.icons, icon).then(() => {
Expand Down
8 changes: 1 addition & 7 deletions packages/gatsby-plugin-manifest/src/gatsby-ssr.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import React from "react"
import { withPrefix } from "gatsby-link"
import { defaultIcons } from "./common.js"


exports.onRenderBody = ({ setHeadComponents }, pluginOptions) => {

const icons = pluginOptions.icons || defaultIcons
const iconPath = icons[0].src.substring(0, icons[0].src.lastIndexOf(`/`))

setHeadComponents([
<link
key={`gatsby-plugin-manifest-link`}
rel="manifest"
href={withPrefix(`${iconPath}/manifest.json`)}
href={withPrefix(`manifest.json`)}
/>,
<meta
key={`gatsby-plugin-manifest-meta`}
Expand Down