Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation to more examples #38

Merged
merged 3 commits into from
Jan 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This addon configures `@storybook/react` to display React Native (RN) projects u
- [Aliasing react native web libraries](#aliasing-react-native-web-libraries)
- [Adding babel plugins](#adding-babel-plugins)
- [Configuring popular libraries](#configuring-popular-libraries)
- [Adding support for static assets and svgs](#adding-support-for-static-assets-and-svgs)
- [Node polyfills for webpack 5](#node-polyfills-for-webpack-5)
- [Known limitations](#known-limitations)

See the [FAQ](https://github.com/storybookjs/addon-react-native-web/blob/main/FAQ.md) for common questions.
Expand Down Expand Up @@ -230,6 +232,54 @@ module.exports = {

</table>

## Adding support for static assets and svgs

Install `@svgr/webpack` and `url-loader`

```js
module.exports = {
/*existing config*/
// to provide a public export for assets
staticDirs: ['<path_to_assets>'],
webpackFinal: async (config) => {
const fileLoaderRule = config.module.rules.find(
(rule) => rule.test && rule.test.test('.svg'),
);

if (fileLoaderRule) {
fileLoaderRule.exclude = /\.svg$/;
}

config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack', 'url-loader'],
});

return config;
},
};
```

## Node polyfills for webpack 5

install `node-polyfill-webpack-plugin`

```js
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

module.exports = {
/*existing config*/
core: {
builder: 'webpack5',
},
webpackFinal: async (config) => {
config.plugins.push(new NodePolyfillPlugin());

return config;
},
};
```

## Known limitations

- Libraries that don't support react-native-web will not work
Expand Down