All Projects → rubenspgcavalcante → Webpack Extension Reloader

rubenspgcavalcante / Webpack Extension Reloader

Licence: mit
A upgrade from 🔥webpack-chrome-extension-reloader🔥, now on all browsers

Programming Languages

typescript
23596 projects

Projects that are alternatives of or similar to Webpack Extension Reloader

Wcer
Webpack plugin to enable reloading while developing Chrome extensions.
Stars: ✭ 71 (-80%)
Mutual labels:  webpack, webpack-plugin, hot-reloading
Webpack Chrome Extension Reloader
🔥 Hot reloading while developing Chrome extensions with webpack 🔥
Stars: ✭ 365 (+2.82%)
Mutual labels:  webpack, webpack-plugin, hot-reloading
Critters
🦔 A Webpack plugin to inline your critical CSS and lazy-load the rest.
Stars: ✭ 2,894 (+715.21%)
Mutual labels:  webpack, webpack-plugin
Copy Webpack Plugin
Copy files and directories with webpack
Stars: ✭ 2,679 (+654.65%)
Mutual labels:  webpack, webpack-plugin
Boundary
Boundary is a CSS+Javascript library for Chrome extension developers to easily create HTML elements that won’t affect or be affected by the current webpage’s CSS. Strongly recommended if you are considering adding a sticker, a sidebar or any overlay box using content script.
Stars: ✭ 59 (-83.38%)
Mutual labels:  extensions, browser-extension
Bundle Buddy Webpack Plugin
🐐🐐🐐🐐 bundle-buddy-webpack-plugin 🐐🐐🐐🐐
Stars: ✭ 199 (-43.94%)
Mutual labels:  webpack, webpack-plugin
Unused Files Webpack Plugin
Glob all files that are not compiled by webpack under webpack's context
Stars: ✭ 210 (-40.85%)
Mutual labels:  webpack, webpack-plugin
Webpack Shell Plugin
Run shell commands either before or after webpack builds
Stars: ✭ 250 (-29.58%)
Mutual labels:  webpack, webpack-plugin
Workerize Loader
🏗️ Automatically move a module into a Web Worker (Webpack loader)
Stars: ✭ 2,135 (+501.41%)
Mutual labels:  webpack, webpack-plugin
Webpack Sentry Plugin
Webpack plugin to upload source maps to Sentry
Stars: ✭ 299 (-15.77%)
Mutual labels:  webpack, webpack-plugin
Webpack Virtual Modules
Webpack Virtual Modules is a webpack plugin that lets you create, modify, and delete in-memory files in a way that webpack treats them as if they were physically presented in the file system.
Stars: ✭ 286 (-19.44%)
Mutual labels:  webpack, webpack-plugin
Webpack Cdn Plugin
A webpack plugin that use externals of CDN urls for production and local node_modules for development
Stars: ✭ 306 (-13.8%)
Mutual labels:  webpack, webpack-plugin
Wxapp Webpack Plugin
📦 微信小程序 webpack 插件
Stars: ✭ 185 (-47.89%)
Mutual labels:  webpack, webpack-plugin
Emojify Webpack Plugin
🦄 Turn your code into emoji
Stars: ✭ 178 (-49.86%)
Mutual labels:  webpack, webpack-plugin
Hard Source Webpack Plugin
www.npmjs.com/package/hard-source-webpack-plugin
Stars: ✭ 2,608 (+634.65%)
Mutual labels:  webpack, webpack-plugin
Scalable React Typescript Boilerplate
⭐️ Scalable micro-framework featuring React and TypeScript
Stars: ✭ 174 (-50.99%)
Mutual labels:  webpack, hot-reloading
Webpack Messages
Beautifully format Webpack messages throughout your bundle lifecycle(s)!
Stars: ✭ 238 (-32.96%)
Mutual labels:  webpack, webpack-plugin
Web Webpack Plugin
alternative for html-webpack-plugin
Stars: ✭ 318 (-10.42%)
Mutual labels:  webpack, webpack-plugin
React Core Boilerplate
Powerful ASP.NET Core 3 templates with React, true server-side rendering and Docker support
Stars: ✭ 169 (-52.39%)
Mutual labels:  webpack, webpack-plugin
Html Res Webpack Plugin
plugin for generating html in webpack
Stars: ✭ 170 (-52.11%)
Mutual labels:  webpack, webpack-plugin

Webpack Extension Reloader

A Webpack plugin to automatically reload browser extensions during development.

npm version Test Status NPM Downloads Codacy Badge Greenkeeper badge

Installing

npm

npm install webpack-extension-reloader --save-dev

yarn

yarn add webpack-extension-reloader --dev

Solution for ...

Have your ever being annoyed while developing a browser extension, and being unable to use webpack-hot-server because it's not a web app but a browser extension?

Well, now you can have automatic reloading!

Note: This plugin doesn't allow Hot Module Replacement (HMR) yet.

What it does?

Basically something similar to what the webpack hot reload middleware does. When you change the code and the webpack trigger and finish the compilation, your extension is notified and then reloaded using the standard browser runtime API.
Check out Hot reloading extensions using Webpack for more background.

How to use

Using as a plugin

Add webpack-extension-reloader to the plugins section of your webpack configuration file. Note that this plugin don't outputs the manifest (at most read it to gather information). For outputing not only the manifest.json but other static files too, use CopyWebpackPlugin.

const ExtensionReloader  = require('webpack-extension-reloader');

plugins: [
  new ExtensionReloader(),
  new CopyWebpackPlugin([
      { from: "./src/manifest.json" },
      { from: "./src/popup.html" },
    ]),
]

You can point to your manifest.json file...

plugins: [
  new ExtensionReloader({
    manifest: path.resolve(__dirname, "manifest.json")
  }),
  // ...
]

... or you can also use some extra options (the following are the default ones):

// webpack.dev.js
module.exports = {
  mode: "development", // The plugin is activated only if mode is set to development
  watch: true,
  entry: {
    'content-script': './my-content-script.js',
    background: './my-background-script.js',
    popup: 'popup',
  },
  //...
  plugins: [
    new ExtensionReloader({
      port: 9090, // Which port use to create the server
      reloadPage: true, // Force the reload of the page also
      entries: { // The entries used for the content/background scripts or extension pages
        contentScript: 'content-script',
        background: 'background',
        extensionPage: 'popup',
      }
    }),
    // ...
  ]
}

Note I: entry or manifest are needed. If both are given, entry will override the information comming from manifest.json. If none are given the default entry values (see above) are used.

And then just run your application with Webpack in watch mode:

NODE_ENV=development webpack --config myconfig.js --mode=development --watch 

Note II: You need to set --mode=development to activate the plugin (only if you didn't set on the webpack.config.js already) then you need to run with --watch, as the plugin will be able to sign the extension only if webpack triggers the rebuild (again, only if you didn't set on webpack.config).

Multiple Content Script and Extension Page support

If you use more than one content script or extension page in your extension, like:

entry: {
  'my-first-content-script': './my-first-content-script.js',
  'my-second-content-script': './my-second-content-script.js',
  // and so on ...
  background: './my-background-script.js',
  'popup': './popup.js',
  'options': './options.js',
  // and so on ...
}

You can use the entries.contentScript or entries.extensionPage options as an array:

plugins: [
  new ExtensionReloader({
    entries: { 
      contentScript: ['my-first-content-script', 'my-second-content-script', /* and so on ... */],
      background: 'background',
      extensionPage: ['popup', 'options', /* and so on ... */],
    }
  }),
  // ...
]

CLI

If you don't want all the plugin setup, you can just use the client that comes with the package.
You can use by installing the package globally, or directly using npx:

npx webpack-extension-reloader

If you run directly, it will use the default configurations, but if you want to customize you can call it with the following options:

npx webpack-extension-reloader --config wb.config.js --port 9080 --no-page-reload --content-script my-content.js --background bg.js --extension-page popup.js

If you have multiple content scripts or extension pages, just use comma (with no spaces) while passing the option

npx webpack-extension-reloader --content-script my-first-content.js,my-second-content.js,my-third-content.js --extension-page popup.js,options.js

Client options

name default description
--help Shows this help
--config webpack.config.js The webpack configuration file path
--port 9090 The port to run the server
--manifest The path to the extension manifest.json file
--content-script content-script The entry/entries name(s) for the content script(s)
--background background The entry name for the background script
--extension-page popup The entry/entries name(s) for the extension pages(s)
--no-page-reload Disable the auto reloading of all pages which runs the plugin

Every time content or background scripts are modified, the extension is reloaded :)
Note: the plugin only works on development mode, so don't forget to set the NODE_ENV before run the command above

Contributing

Please before opening any issue or pull request check the contribution guide.

License

This project is under the MIT LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected]