From 4b56d48f407d3b8a50c8d5f8049a2d41a072136a Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sun, 6 Jan 2019 13:42:54 +0000 Subject: [PATCH] Nicer manifest merging --- TODO.org | 3 ++- package.json | 1 + webpack.config.js | 26 ++++++++++++++------------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/TODO.org b/TODO.org index 04adebe..b18c042 100644 --- a/TODO.org +++ b/TODO.org @@ -28,7 +28,8 @@ npm run flow * TODO [#B] docs on using * TODO [#B] circleci? -* TODO [#D] nicer manifest? +* DONE [#D] nicer manifest? + CLOSED: [2019-01-06 Sun 13:43] * TODO [#D] do not minfy for dev * TODO [#C] motivation * TODO [#B] doesn't look like hotkey working unless you manually rebind.. wtf? diff --git a/package.json b/package.json index 25fc1db..e6f4dbb 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "webpack": "^4.28.3", "webpack-cli": "^3.2.0", "webpack-dev-server": "^3.1.14", + "webpack-extension-manifest-plugin": "^0.4.3", "write-file-webpack-plugin": "^4.5.0" }, "dependencies": { diff --git a/webpack.config.js b/webpack.config.js index b61f26b..34d6528 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,7 +5,11 @@ var webpack = require("webpack"), CleanWebpackPlugin = require("clean-webpack-plugin"), CopyWebpackPlugin = require("copy-webpack-plugin"), HtmlWebpackPlugin = require("html-webpack-plugin"), - WriteFilePlugin = require("write-file-webpack-plugin"); + WriteFilePlugin = require("write-file-webpack-plugin"), + WebpackExtensionManifestPlugin = require("webpack-extension-manifest-plugin"); + +const pkg = require('./package.json'); +const baseManifest = require('./src/manifest.json'); // load the secrets var alias = {}; @@ -65,17 +69,15 @@ var options = { new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify(env.NODE_ENV) }), - new CopyWebpackPlugin([{ - from: "src/manifest.json", - transform: function (content, path) { - // generates the manifest file using the package.json informations - return Buffer.from(JSON.stringify({ - description: process.env.npm_package_description, - version: process.env.npm_package_version, - ...JSON.parse(content.toString()) - })) - } - }]), + new WebpackExtensionManifestPlugin({ + config: { + base: baseManifest, + extend: { + version: pkg.version, + description: pkg.description, + } + } + }), new HtmlWebpackPlugin({ template: path.join(__dirname, "src", "popup.html"), filename: "popup.html",