Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
@webextension-toolbox/webextension-toolbox
Advanced tools
Framework for WebExtensions (Firefox, Chrome, Opera, Edge)
Small cli toolbox for creating cross-browser WebExtensions.
If you want to get started quickly check out the yeoman generator for this project.
chrome
) (auto polyfilled)opera
) (auto polyfilled)edge
) (auto polyfilled)firefox
)safari
)npm install @babel/preset-react --save-dev
{
"presets": [
"@babel/preset-react"
]
}
The build
task creates bundles for:
.xpi
).zip
).crx
).zip
).zip
)Validates your manifest.json
while compiling.
You can skip this by adding --validateManifest
to your build
or dev
command.
Uses default fields (name
, version
, description
) from your package.json
Allows you to define vendor specific manifest keys.
manifest.json
"name": "my-extension",
"__chrome__key": "yourchromekey",
"__chrome|opera__key2": "yourblinkkey"
If the vendor is chrome
it compiles to:
"name": "my-extension",
"key": "yourchromekey",
"key2": "yourblinkkey"
If the vendor is opera
it compiles to:
"name": "my-extension",
"key2": "yourblinkkey"
else it compiles to:
"name": "my-extension"
The WebExtension specification is currently supported on Chrome, Firefox, Edge (Chromium) and Safari (Safari Web Extension’s Browser Compatibility).
This toolbox no longer provides any polyfills for cross-browser support. If you need polyfills e.g. between 'browser' and 'chrome', we recommend detecting the browser during the build time using process.env.VENDOR.
This toolbox comes with babel-preset-env. Feel free add custom configuration if you need any custom polyfills.
$ npm install -g webextension-toolbox
dist/<vendor>
.process.env.NODE_ENV
to development
.process.env.VENDOR
to the current vendor.$ webextension-toolbox dev <vendor> [..options]
$ webextension-toolbox dev --help
$ webextension-toolbox dev chrome
$ webextension-toolbox dev firefox
$ webextension-toolbox dev opera
$ webextension-toolbox dev edge
dist/<vendor>
.process.env.NODE_ENV
to production
.process.env.VENDOR
to the current vendor.packages
.Usage: build [options] <vendor>
Compiles extension for production
Options:
-s, --src [src] specify source directory (default: "app")
-t, --target [target] specify target directory (default: "dist/[vendor]")
-d, --devtool [devtool] controls if and how source maps are generated (default: false)
-m, --no-minimize disables code minification
-v, --vendorVersion [vendorVersion] last supported vendor (default: current)
--validateManifest [validateManifest] validate manifest syntax (default: false)
-h, --help output usage information
Always use the WebExtension browser API. Webextension-Toolbox will polyfill it for you in chrome and opera.
All javascript files located at the root of your ./app
or ./app/scripts
directory will create a seperate bundle.
app | dist |
---|---|
app/background.js | dist/<vendor>/background.js |
app/scripts/background.js | dist/<vendor>/scripts/background.js |
app/some-dir/some-file.js | Will be ignored as entry file. |
app/scripts/some-dir/some-file.js | Will be ignored as entry file. |
In order to extend our usage of webpack
, you can define a function that extends its config via webextension-toolbox.config.js
in your project root.
module.exports = {
webpack: (config, { dev, vendor }) => {
// Perform customizations to webpack config
// Important: return the modified config
return config;
},
};
As WebExtension Toolbox uses webpack’s devtool feature under the hood, you can also customize the desired devtool with the --devtool
argument.
For example, if you have problems with source maps on Firefox, you can try the following command:
webextension-toolbox build firefox --devtool=inline-cheap-source-map
Please see Issue #58 for more information on this
If want to develop browser extensions for Firefox only web-ext might be a better fit for you, since it supports, extension signing, better manifest validation and auto mounting.
Nevertheless if you want to develop cross browser extensions using
webextension-toolbox might be your tool of choice.
Copyright 2021 Henrik Wenz
This project is free software released under the MIT license.
[5.0.0] - 2021-04-05
--no-manifest-validation
)--port
) #592browser
global and thus this should be used over chrome
. Therefore the removal of pollyfill was nessecary. You can add it back yourself in your own projects if neededFAQs
Framework for WebExtensions (Firefox, Chrome, Opera, Edge)
We found that @webextension-toolbox/webextension-toolbox demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.