webpack-inject-entry-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

Webpack Inject Entry Plugin

A webpack plugin to inject code into the bundle

What is this? 🧐

A webpack plugin to inject a filepath into a webpack entry. This can be used to build webpack plugins that inject code into the bundle.

Compatible with both Webpack 4 and 5.

Examples 🚀

Usage in a webpack plugin:

import InjectEntryPlugin from "webpack-inject-entry-plugin";

export class MyPlugin {
  constructor(options) {
    this.options = options;
  }

  apply(compiler) {
    new InjectEntryPlugin({
      entry: "main",
      filepath: "./path/to/my/entry/file.js",
    }).apply(compiler);
  }
}

Usage in webpack.config.js:

const InjectEntryPlugin = require("webpack-inject-entry-plugin").default;

module.exports = {
  plugins: [
    new InjectEntryPlugin({
      entry: "main",
      filepath: "./service-worker.js",
    }),
  ],
};

Installation & Usage 📦

  1. Add this package to your project:
    • yarn add webpack-inject-entry-plugin

API Overview 🛠

Name Description Type
entry The name of the webpack entry. string
filepath The filepath to the source code to inject. string

Contributing 👫

PR's and issues welcomed! For more guidance check out CONTRIBUTING.md

Licensing 📃

See the project's MIT License.

Package Sidebar

Install

npm i webpack-inject-entry-plugin

Weekly Downloads

268

Version

0.0.4

License

MIT

Unpacked Size

8.06 kB

Total Files

5

Last publish

Collaborators

  • tatethurston