Sorry, I wanted to write offerPlugin, not definePlugin. DefinePlugin will replace the variable in your code directly and will not create a global one.
You can use securityPlugin to set the global configuration variable from the module file you created:
in the configuration of your web package:
plugins: [ new webpack.ProvidePlugin({ 'config': 'config' }) ... ], resolve: { alias: { 'config': path.resolve(__dirname, './config') }, extensions: ['.js'] }
and config will be set as global for exporting the config.js file.
Then you can access this global and change it at different entry points. For example, you can do config.with_admin_mode = true; in entry1.js and config.with_admin_mode = false; in entry2.js.
Another solution would be to set a global variable in the window directly from your modules, for example. window.with_admin_mode = true;
Jusmalcolm
source share