Merge webpack plugin configuration / DefinePlugin
See original GitHub issueCurrent Behavior
If you add a DefinePlugin section to your webpack.haul.js / config plugins, it will override the default DefinePlugin stuff set up for you by makeReactNativeConfig. For example, you could have a webpack.haul.js like:
module.exports = ({ platform }) => ({
entry: `./index.js`,
plugins: [
new webpack.DefinePlugin({
'API_HOST': JSON.stringify(process.env.API_HOST),
}),
]
});
If you try to run your app, you’ll get mysterious errors such as undefined variable __DEV__, but after looking into it the problem is that the plugins are overridden.
Expected Behavior
I think there are a few options here.
- haul should be able to intelligently merge plugins
- haul should provide documentation / a clear path for merging of plugins
- Just for my specific case, haul should provide the ability to forward environment variables or other fine grained configuration.
Haul Configuration (webpack.haul.js)
Sufficient to reproduce:
module.exports = ({ platform }) => ({
entry: `./index.js`,
plugins: [],
});
Your Environment
| software | version |
|---|---|
| Haul | v1.0.0-beta.13 |
| react-native | 0.53.0 |
| node | 9.5 |
| npm or yarn | 1.3.2 |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
DefinePlugin
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 >How to use the webpack-merge.strategy function in ...
To help you get started, we've selected a few webpack-merge.strategy ... the settings that are common to prod and dev /** * Webpack...
Read more >webpack merge definePlugin process.env.NODE_ENV ...
config files. I am trying to pass the node_env (or any other variabels);. How can I access the process env variable from the...
Read more >webpack-merge JavaScript and Node.js code examples
configs/webpack.renderer.dev.js/merge.smart. merge.smart(baseConfig, { mode: "development", plugins: [ new webpack.DefinePlugin({ 'process.env.
Read more >webpack 4 - How to have separate build outputs ... - Ed Spencer
This is because the mode flag can only be used in the DefinePlugin phase, where it is mapped to the NODE_ENV variable. The...
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

That’s a good point. Although looking at
webpack-mergesources I’m not sure if it can merge plugins configuration, but it can swap plugins though. Anyway,babel-plugin-transform-inline-environment-variablesworks perfectly for my usecase, so it’s okay. Thanks for your help. Keep it up, Haul is a great tool 😃@baygeldin with the new config format you can use something like webpack-merge to do the merging. I think it’s better that we don’t try to solve this problem because there are other tools which try to solve it already.