Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zhanghongen/inject-webpack

Inject code, support webpack-4、5 and module-federation
https://github.com/zhanghongen/inject-webpack

code inject inject-webpack module-federation webpack webpack-plugin webpack4 webpack5

Last synced: 4 months ago
JSON representation

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

Awesome Lists containing this project

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\//]
}),
]
}
```