# inject-webpack

> Inject code support webpack-4、5 and module-federation

Latest version **0.4.4** (published 2023-07-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install inject-webpack
pnpm add inject-webpack
yarn add inject-webpack
bun add inject-webpack
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.4 |
| Published | 2023-07-04 |
| First published | 2022-11-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 15.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | zhanghongen |
| Keywords | inject, module-federation, webpack, plugin |

## Links

- npm: https://www.npmjs.com/package/inject-webpack
- Repository: https://github.com/zhangHongEn/inject-webpack
- Homepage: https://github.com/zhangHongEn/inject-webpack#readme
- Issues: https://github.com/zhangHongEn/inject-webpack/issues
- npm.io page: https://npm.io/package/inject-webpack

## Dependencies (1)

- [webpack-virtual-modules](https://npm.io/package/webpack-virtual-modules.md) ^0.4.6

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.4.4 (latest) — 2023-07-04
- 0.1.5-beta.0 (beta) — 2022-11-24
- 0.4.3 — 2023-02-25
- 0.4.2 — 2022-12-05
- 0.4.1 — 2022-12-02
- 0.4.0 — 2022-12-01
- 0.3.2 — 2022-11-30
- 0.3.1 — 2022-11-29
- 0.3.0 — 2022-11-29
- 0.2.0 — 2022-11-24
- 0.1.8 — 2022-11-24
- 0.1.7 — 2022-11-24
- 0.1.6 — 2022-11-24
- 0.1.5 — 2022-11-15
- 0.1.4 — 2022-11-14
- … 4 more at https://npm.io/package/inject-webpack/versions

## README

# inject-webpack

[![npm](https://img.shields.io/npm/v/inject-webpack.svg)](https://www.npmjs.com/package/inject-webpack)

webpack inject plugin

### API

``` js
// webpack.config.js
const Inject = require("inject-webpack")

module.exports = {
    entry: {
        a,
        b
    },
    plugins: [
        new ModuleFederation({
          filename: "remoteEntry.js",
          exposes: {
            "App": "src/App",
            "Button": "src/Button"
          },
        }),
        new Inject(() => {
            return `console.log("inject code1")`
        }, {
            // entry: a、b、webpack-dev-server.....
            // remoteEntry: remoteEntry.js
            // exposesEntry: src/App、src/Button
            // default value is ["entry", "remoteEntry"]
            scopes: ["entry", "remoteEntry", "exposesEntry"],
            // In addition to the entry files corresponding to scopes, code is also injected into these files
            extraInjection: [/src\/a\//]
        }),
    ]
}
```

---
_Source: https://npm.io/package/inject-webpack · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
