This Webpack loader inserts data from package.json into a your manifest.json to ensure it's always up-to-date. (who remembers to update the version field every time?)
This is handy when writing chrome extensions. You may also be interested in the web-accessible resources plugin.
This script was originally written by SO user108471.
The following fields are copied from webpack.json to your manifest.json:
name
description
version
author
homepage_url
yarn add -D manifest-package-loader
Add a rule to your webpack.config.json
:
// webpack.config.js
module.exports = {
...
module: {
rules: [
...
{
test: /^manifest\.json$/,
use: [
{
loader: 'file-loader',
options: { name: '[name].[ext]' }
},
'manifest-package-loader'
]
}
]
}
...
}
Make sure to require or import './manifest.json' in any of your javascript files. If you omit this step, Webpack will think the manifest is dead code.
// index.js
import './manifest.json'
Please file an issue on GitHub.
MIT, be free.