npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-plugin-web-extension-hot-reload

v1.0.2

Published

A Vite plugin for developing web extensions with hot reload using web-ext

Downloads

18

Readme

Vite Plugin Web Extension Hot Reload

A Vite plugin for developing web extensions with hot reload using web-ext. This plugin ensures that your web extension is reloaded automatically in the browser whenever you make changes, making the development process more efficient and convenient.

Installation

To install the plugin, use npm:

npm install vite-plugin-web-extension-hot-reload --save-dev

Usage

To use the plugin, you need to configure your vite.config.js file and set up your development command to use vite build --watch.

Step 1: Update vite.config.js

import { defineConfig } from "vite";
import webExtPlugin from "vite-plugin-web-extension-hot-reload";

export default defineConfig({
  plugins: [
    webExtPlugin({
      sourceDir: "dist", // Adjust the sourceDir if necessary
    }),
  ],
});

Step 2: Update package.json Scripts

Add or update the dev script in your package.json to use vite build --watch:

{
  "scripts": {
    "dev": "vite build --watch"
  }
}

Step 3: Run the Development Command

To build and watch for changes, use the following command:

npm run dev

This will build your project and watch for changes. If changes are detected, it will rebuild the project and use web-ext to reload the extension in the browser.

Options

The plugin accepts an optional configuration object with the following properties:

  • sourceDir (string): The source directory for the web extension. Default is dist.

Example Project Setup

Here is a quick example of what the setup might look like in a Vite project:

Directory Structure

my-vite-project/
├── node_modules/
├── public/
├── src/
├── dist/
├── index.html
├── package.json
└── vite.config.js

package.json

{
  "name": "my-vite-project",
  "version": "1.0.0",
  "description": "A Vite project using vite-plugin-web-extension-hot-reload",
  "scripts": {
    "dev": "vite build --watch",
    "build": "vite build"
  },
  "dependencies": {
    "vite-plugin-web-extension-hot-reload": "^1.0.0"
  }
}

vite.config.js

import { defineConfig } from "vite";
import webExtPlugin from "vite-plugin-web-extension-hot-reload";

export default defineConfig({
  plugins: [
    webExtPlugin({
      sourceDir: "dist", // Adjust the sourceDir if necessary
    }),
  ],
});

Why This Plugin?

While there are other plugins like vite-plugin-web-extension that provide a more abstracted solution, this plugin aims to be simpler and more focused. It allows you to handle the manifest and other configurations yourself, providing more control over your project. This plugin specifically handles hot reloading of your web extension, making it a straightforward and flexible tool for developers who prefer more granular control over their build process.

License

This project is licensed under the MIT License.