mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-24 02:02:53 +02:00
32 lines
956 B
Markdown
32 lines
956 B
Markdown
# WebExtension Webpack Example
|
|
A minimal example of how to use npm modules from within a WebExtension.
|
|
The example package used by this extension is `left-pad`, an essential package
|
|
in almost any situation.
|
|
|
|
## What it does
|
|
This setup takes a background and a content script entrypoint and outputs them
|
|
to their respective target.
|
|
|
|
## What it could do
|
|
This could be infinitely extended - injecting global jQuery, adding babel,
|
|
react/jsx, css modules, image processing and so on.
|
|
|
|
## What it shows
|
|
|
|
- How to use npm or custom modules in a WebExtension.
|
|
|
|
## How to build it
|
|
|
|
- `npm install`
|
|
- `npm run build`
|
|
|
|
The WebExtension in the [dist](dist/) folder should now work.
|
|
|
|
## What about Browserify?
|
|
Browserify works just as well as webpack for extensions, in the end it's a
|
|
personal choice about your prefered tool.
|
|
|
|
## Live-development
|
|
Additionally to watching the folder with your `manifest.json` in it, you will also
|
|
have to run webpack in watch mode.
|