Skip to content

Commit

Permalink
bundle webextension-polyfill via webpack
Browse files Browse the repository at this point in the history
requires another patch to @webextension-toolbox/webextension-toolbox due to default config file path not resolving with find-up (sindresorhus/find-up#36 (comment))
  • Loading branch information
rthaut committed Jan 23, 2024
1 parent 6a30dfe commit b4b3aae
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .eslintrc
@@ -1,12 +1,16 @@
{
"env": {
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"prettier",
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaVersion": 2019
},
"root": true,
"rules": {
"no-unused-vars": [
Expand Down
13 changes: 12 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -50,7 +50,8 @@
"react-dropzone": "14.2.3",
"react-router-dom": "5.3.4",
"react-use": "17.4.3",
"semver": "7.5.4"
"semver": "7.5.4",
"webextension-polyfill": "^0.10.0"
},
"devDependencies": {
"@babel/preset-react": "^7.23.3",
Expand Down
@@ -0,0 +1,44 @@
diff --git a/node_modules/@webextension-toolbox/webextension-toolbox/dist/command.js b/node_modules/@webextension-toolbox/webextension-toolbox/dist/command.js
index 260881b..a83e1b4 100644
--- a/node_modules/@webextension-toolbox/webextension-toolbox/dist/command.js
+++ b/node_modules/@webextension-toolbox/webextension-toolbox/dist/command.js
@@ -24,7 +24,7 @@ const index_1 = require("./index");
.command("dev")
.description("Compiles extension in devmode")
.argument("<vendor>", "The Vendor to compile")
- .option("-c, --config [config]", "specify config file path", "./webextension-toolbox.config.js")
+ .option("-c, --config [config]", "specify config file path", "webextension-toolbox.config.js")
.option("-s, --src [src]", "specify source directory", "app")
.option("-t, --target [target]", "specify target directory", "dist/[vendor]")
.option("-d, --devtool [string | false]", "controls if and how source maps are generated", "cheap-source-map")
@@ -39,7 +39,7 @@ const index_1 = require("./index");
.command("build")
.description("Compiles extension for production")
.argument("<vendor>", "The Vendor to compile")
- .option("-c, --config [config]", "specify config file path", "./webextension-toolbox.config.js")
+ .option("-c, --config [config]", "specify config file path", "webextension-toolbox.config.js")
.option("-s, --src [src]", "specify source directory", "app")
.option("-t, --target [target]", "specify target directory", "dist/[vendor]")
.option("-d, --devtool [string | false]", "controls if and how source maps are generated", false)
diff --git a/node_modules/@webextension-toolbox/webextension-toolbox/src/command.ts b/node_modules/@webextension-toolbox/webextension-toolbox/src/command.ts
index 2ea3bec..ce4dcc9 100644
--- a/node_modules/@webextension-toolbox/webextension-toolbox/src/command.ts
+++ b/node_modules/@webextension-toolbox/webextension-toolbox/src/command.ts
@@ -30,7 +30,7 @@ import { build, dev } from "./index";
.option(
"-c, --config [config]",
"specify config file path",
- "./webextension-toolbox.config.js"
+ "webextension-toolbox.config.js"
)
.option("-s, --src [src]", "specify source directory", "app")
.option(
@@ -76,7 +76,7 @@ import { build, dev } from "./index";
.option(
"-c, --config [config]",
"specify config file path",
- "./webextension-toolbox.config.js"
+ "webextension-toolbox.config.js"
)
.option("-s, --src [src]", "specify source directory", "app")
.option(
15 changes: 15 additions & 0 deletions webextension-toolbox.config.js
@@ -0,0 +1,15 @@
var webpack = require("webpack");

module.exports = {
webpack: (config, { vendor }) => {
if (["chrome", "opera", "edge"].includes(vendor)) {
config.plugins.push(
new webpack.ProvidePlugin({
browser: "webextension-polyfill",
}),
);
}

return config;
},
};

0 comments on commit b4b3aae

Please sign in to comment.