[DefinePlugin] Be able to define globals by entry points ?

Do you want to request a feature or report a bug?
feature

If this is a feature request, what is motivation or use case for changing the behavior?
My main goal is to create a bundle per role on my app. I discovered the DefinePlugin, and looks pretty cool but it would be better if we could define globals by entry points. This way i could have multiple entry on the same file but something like :

/* webpack config */
entry: {
    "user": "path_to_client_index",
    "admin": "path_to_client_index",
}

new webpack.DefinePlugin({
    entry: {
        "user" : {
            __ROLE__: "'" + "user" + "'",
        },
        "admin" : {
            __ROLE__: "'" + "admin" + "'",
        },
    }
})

/* entry index.js */
import route from "routes/" + __ROLE__;

Author: Fantashit

2 thoughts on “[DefinePlugin] Be able to define globals by entry points ?

  1. Is there any other way to get custom variables into individual entries? i do not wanner to create mulitiple configs, just the define plugin

  2. +1 to this. When building “multipage” isomorphic React apps where you have one clientside bundle per page, it would be handy to do it all in one configuration with entry points.

Comments are closed.