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'exportdefault {
mode: 'development',
entry: {
background: path.join(__dirname, 'background.ts'),
contentScript: path.join(__dirname, 'contentScript.ts'),
},
plugins: [
...newCrxLiveReloadWebpackPlugin({
// 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 knowwriteToDisk: 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.
The npm package @dumlj/crx-live-reload-webpack-plugin receives a total of 1 weekly downloads. As such, @dumlj/crx-live-reload-webpack-plugin popularity was classified as not popular.
We found that @dumlj/crx-live-reload-webpack-plugin 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.
Package last updated on 27 Nov 2023
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.
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.