[DefinePlugin] Be able to define globals by entry points ?
See original GitHub issueDo 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__;
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:7
Top Results From Across the Web
DefinePlugin | webpack
The DefinePlugin replaces variables in your code with other values or expressions at compile time. This can be useful for allowing different behavior ......
Read more >Define global variable with webpack - Stack Overflow
There are several way to approach globals: 1. Put your variables in a module. Webpack evaluates modules only once, so your instance remains ......
Read more >Optimizing your JavaScript Bundle | DefinePlugin Webpack
Here we define a constant which would be available in the global scope of our bundle -- ... This file will be the...
Read more >Environment Variables : Webpack config using DefinePlugin
“The DefinePlugin allows you to create global constants which can be configured at compile time.” We can use Define plugin in webpack.config ...
Read more >Environment Variables - SurviveJS
Webpack's DefinePlugin enables replacing free variables so that you can convert if (process.env. ... Starting from webpack 4, process.env.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
+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.
Is there any other way to get custom variables into individual entries? i do not wanner to create mulitiple configs, just the define plugin