Add documentation for Node.js module aliasing

Close #1315
This commit is contained in:
MoOx
2019-03-29 19:40:02 +01:00
committed by Nicolas Gallagher
parent cc99391f9d
commit 70e3ea8b57
+17 -1
View File
@@ -50,7 +50,7 @@ Now you can create your components and applications with the React Native API.
## Configuring Babel
If you need to do the aliasing with Babel you can use
[Babel](https://babeljs.io/) supports module aliasing using
[babel-plugin-module-resolver](https://www.npmjs.com/package/babel-plugin-module-resolver)
```
@@ -92,6 +92,22 @@ You may also need to include a custom libdef
([example](https://gist.github.com/paularmstrong/f60b40d16fc83e1e8e532d483336f9bb))
in your config.
## Configuring Node.js
Node.js can alias `react-native` to `react-native-web` using
[`module-alias`](https://www.npmjs.com/package/module-alias). This is useful if
you want to pre-render the app (e.g., server-side rendering or build-time
rendering).
```js
// Install the `module-alias` package as a dependency first
const moduleAlias = require("module-alias");
moduleAlias.addAliases({
"react-native": require.resolve("react-native-web"),
});
moduleAlias();
```
## Other notes
### Safari flexbox performance