Skip to content

A webpack plugin to populate the web_accessible_resources clause in manifest.json

License

Notifications You must be signed in to change notification settings

bronson/web-accessible-resources-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

web-accessible-resources-webpack-plugin

This plugin adds filenames in your webpack to the web_accessible_resources clause in your manifest.json. You don't need to maintain a list of images manually anymore.

This is handy when writing chrome extensions, especially when paired with the manifest package loader.

Install

  • yarn add -D web-accessible-resources-webpack-plugin

Usage

// webpack.config.js

const WebAccessibleResourcesPlugin = require('web-accessible-resources-webpack-plugin')

module.exports = {
  ...
  plugins: [
    new WebAccessibleResourcesPlugin(/\.(png|jpg|gif)$/)
  ]
}

Now images required by your source files will be mentioned in web_accessible_resources.

For more flexibility, you can specify a function instead of the regular expression:

  new WebAccessibleResourcesPlugin( (name) => ['a.jpg', 'b.jpg'].includes(name) )

Output

Example output in your manifest.json:

{
  ...
  "web_accessible_resources": [
    "header.png",
    "landscape.jpg",
    "icon.png"
  ]
}

Contributing

Please file an issue on GitHub.

License

MIT, be free.

About

A webpack plugin to populate the web_accessible_resources clause in manifest.json

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published