dynamically generate version field for manifest.json from package.json

This commit is contained in:
abhijithvijayan 2019-10-25 16:48:45 +05:30
parent dd18c91b21
commit 3fc3d01d17
4 changed files with 17 additions and 7 deletions

View File

@ -1,7 +1,5 @@
{
"manifest_version": 2,
"name": "Sample WebExtension",
"version": "0.0.1",
"author": "abhijithvijayan",
"short_name": "Sample Name",
"description": "Sample description",
@ -10,6 +8,7 @@
"persistent": false,
"scripts": ["js/background.js"]
},
"manifest_version": 2,
"minimum_chrome_version": "49",
"permissions": ["tabs", "storage", "http://*/*", "https://*/*"],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",

View File

@ -1,7 +1,5 @@
{
"manifest_version": 2,
"name": "Sample WebExtension",
"version": "0.0.1",
"author": "abhijithvijayan",
"short_name": "Sample Name",
"description": "Sample description",
@ -9,6 +7,7 @@
"background": {
"scripts": ["js/background.js"]
},
"manifest_version": 2,
"permissions": ["tabs", "storage", "http://*/*", "https://*/*"],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"icons": {

View File

@ -1,7 +1,5 @@
{
"manifest_version": 2,
"name": "Sample WebExtension",
"version": "0.0.1",
"developer": {
"name": "abhijithvijayan"
},
@ -12,6 +10,7 @@
"persistent": false,
"scripts": ["js/background.js"]
},
"manifest_version": 2,
"minimum_opera_version": "36",
"permissions": ["tabs", "storage", "http://*/*", "https://*/*"],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",

View File

@ -35,7 +35,20 @@ module.exports = {
}),
new CopyWebpackPlugin([
{ from: 'src/assets', to: 'assets' },
{ from: `src/manifests/${process.env.TARGET}.json`, to: 'manifest.json' },
{
from: `src/manifests/${process.env.TARGET}.json`,
// expose and write the allowed env vars on the compiled bundle
transform(content, path) {
// generates the manifest file using the package.json informations
return Buffer.from(
JSON.stringify({
version: process.env.npm_package_version,
...JSON.parse(content.toString()),
})
);
},
to: 'manifest.json',
},
]),
new HtmlWebpackPlugin({
template: 'src/options.html',