renative
renative copied to clipboard
Webpack configs should be merged using webpack-merge
Describe the bug
When using platforms.web.webpackConfig.extend
to extend some of the webpack configs for web
, the webpack configs are currently merged using a spread operator ...extend
. This means any object we specify in platforms.web.webpackConfig.extend
, for example resolve
, will override the default equivalent entirely instead of being merged with it.
To Reproduce
- In
renative.json
, add the following:
"platforms": {
"web": {
"webpackConfig": {
"extend": {
"resolve": {
"alias": {
"my-module": "some_path"
}
}
}
}
}
}
- The build won't succeed, for example most
react-native
modules will not be found anymore, TypeScript file extensions would not necessarily be included, etc. This is a result ofextensions
and other aliases being removed since spreading the content of theextend
object above will override entirely its properties and not deep merge them.
Expected behavior All webpack configs are always merged using webpack-merge so that configs can be extended and not overriden.
Screenshots or copy&paste
This is where I believe using webpack-merge
would be better, for example, in platformBuilds/<projectName>_web/webpack.config.dev.js
:
module.exports = {
entry: C.entry,
devServer: C.devServer,
output: C.output,
module: {
rules: [C.Rules.babel, C.Rules.css, C.Rules.image, C.Rules.fonts, C.Rules.sourcemap],
},
plugins,
resolve: {
symlinks: false,
extensions: C.extensions,
alias: C.aliases,
},
...config.extend || {} // this will override `resolve` entirely if `config.extend` contains the same property
};
Desktop:
- OS: OSX
- Node Version: v10.16.3
- RNV Version: 0.31.3
@mikiest thanks for reporting this issue. Is this still reproduced on latest rnv version?
- test rn-web engine sanity
- demonstrate webpack override and document
- if 1 and 2 ok then we can close this and open a new ticket for proper extendability of webpack config
@mikiest should be fixed with 1.0.0-rc.12