antony / sveltekit-adapter-browser-extension

Build browser extensions with Svelte (early prototype)
160 stars 19 forks source link

Customize manifest.json #3

Closed andreasmcdermott closed 2 years ago

andreasmcdermott commented 2 years ago

I'd like a way to modify the manifest file as part of the config.

Currently I've made the following changes to my local version:

My config:

adapter: adapter({
  manifest: {
    name: 'My Extension',
    icons: { 48: './static/icon.png' },
    permissions: [
    'storage'
    ]
  }
}),

And the following changes to the adapter:

export default function ({ pages = 'build', assets = pages, manifest = {}, fallback } = {}) {
  function generate_manifest (html) {
    return JSON.stringify({
      browser_action: {
      default_title: manifest.name || 'Todo',
    default_popup: 'index.html'
       },
      content_security_policy: generate_csp(html),
      manifest_version: 2,
      name: manifest.name || 'TODO',
      version: '0.1',
      icons: manifest.icons,
      permissions: manifest.permissions
    }, null, 2)
  }

  ...
}

I know this is on the roadmap, and I'm happy to contribute the above code or a different solution if needed.

antony commented 2 years ago

Hi! Try the latest version - the manifest is now merged with your own :)