inject-webpack
v0.4.4
Published
Inject code support webpack-4、5 and module-federation
Downloads
458
Maintainers
Readme
inject-webpack
webpack inject plugin
API
// 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\//]
}),
]
}