Socket
Socket
Sign inDemoInstall

@dumlj/crx-live-reload-webpack-plugin

Package Overview
Dependencies
3
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @dumlj/crx-live-reload-webpack-plugin

Livereload over SSE for develop Chrome Extension.


Version published
Weekly downloads
188
decreased by-11.32%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

License: MIT  Github Repo  NPM Version  See Docs  codecov 

Crx Live Reload Webpack Plugin

Livereload over SSE for develop Chrome Extension.

BACKGROUND

Since Chrome extensions can only load local files, devServer hot reload does not work (only the browser can be reloaded or the scripts can be re-executed remotely). We need to use scripts to make it reload automatically, which contains the background and content-script modules.

FEATURE

  • Automatically inject reboot scripts.
  • Both background and content-script can use reboot capabilities.

INSTALL

# use npm
$ npm install --dev @dumlj/crx-live-reload-webpack-plugin
# use yarn
$ yarn add --dev @dumlj/crx-live-reload-webpack-plugin
# use pnpm
$ pnpm add @dumlj/crx-live-reload-webpack-plugin -D

USAGE

import { CrxLiveReloadWebpackPlugin } from '@dumlj/crx-live-reload-webpack-plugin'

export default {
  mode: 'development',
  entry: {
    background: path.join(__dirname, 'background.ts'),
    contentScript: path.join(__dirname, 'contentScript.ts'),
  },
  plugins: [
    ...new CrxLiveReloadWebpackPlugin({
      // enter devServer host and port
      // chrome extension can not mount files online.
      host: '127.0.0.1',
      port: 8080,
    }),
  ],
  devServer: {
    hot: true,
    // livereload can not reboot background.js, close it.
    liveReload: false,
    devMiddleware: {
      // as you know
      writeToDisk: true,
    },
  },
}

LIVE DEMO

Since I can't Mock Chrome, please open the console to view the logs.😅 And try to change background.js or contentScript.js files.

Webpack DevServer port is 8080, Static Server port is 3000. In real environment, Chrome Extension will mount ./build folder.

INTERNAL DEPENDENCIES

@dumlj/crx-live-reload-webpack-plugin
└─┬ @dumlj/seed-webpack-plugin
  ├─┬─ @dumlj/feature-updater
  │ ├─── @dumlj/shell-lib
  │ ├─── @dumlj/util-lib
  │ └─── @dumlj/mock-libPRIVATE
  └─── @dumlj/mock-libPRIVATE

FAQs

Last updated on 11 Mar 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc