inject-webpack

0.4.4 • Public • Published

inject-webpack

npm

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

/inject-webpack/

    Package Sidebar

    Install

    npm i inject-webpack

    Weekly Downloads

    849

    Version

    0.4.4

    License

    ISC

    Unpacked Size

    15.8 kB

    Total Files

    12

    Last publish

    Collaborators

    • zhanghongen