Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/zhanghongen/inject-webpack
- Owner: zhangHongEn
- Created: 2022-12-01T15:55:44.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-04T06:59:56.000Z (over 1 year ago)
- Last Synced: 2024-09-21T21:44:20.193Z (4 months ago)
- Topics: code, inject, inject-webpack, module-federation, webpack, webpack-plugin, webpack4, webpack5
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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\//]
}),
]
}
```