Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Update babel plugin docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rayan1810 authored Sep 12, 2023
1 parent ec4c37d commit 72731ee
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions example/storybook/src/advanced/BabelPlugins/index.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,32 @@ import { Box, AppProvider } from '@gluestack/design-system';

@gluestack-style/babel-plugin-styled-resolver transpiles your `styled` function calls and resolves the `component styling` in build time. It also generates all the `CSS rules` and style ids based on which these CSS styles are applied on the component. Doing this saves tons of time on runtime because all your style calculation is already done and all your app has to do is to inject this style into a style tag and viola! All your styles appear instantaneously. This helps us to improve the performance of the apps 5-6 times. If you provide the `components` option then it also resolves the inline styles of the components created using `@gluestack-style/react`.

## Installation Steps:

1. Installing babel-plugin-styled-resolver:

```bash
yarn add @gluestack-style/babel-plugin-styled-resolver
```

2. Add Babel plugin to your app babel.config.js

```bash
const path = require('path');
const gluestackStyleResolver = require('@gluestack-style/babel-plugin-styled-resolver');
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
gluestackStyleResolver,
],
};
};
```

3. Just make sure your `babel.config.js` and `gluestack-style.config.js/ts` are in the same directory. We suggest you keep both of them at the root of your app codebase.

### **Let us see how this Babel plugin works.**

- First, it traverses your files and tries to find `styled` imported from `@gluestack-style/react`.
Expand Down Expand Up @@ -54,33 +80,7 @@ Here’s a small diagram explaining how the flow works:
</Box>
</AppProvider>

Your code gets transpiled in the build files like this:

## Installation Steps:

1. Installing babel-plugin-styled-resolver:

```bash
yarn add @gluestack-style/babel-plugin-styled-resolver
```

2. Add Babel plugin to your app babel.config.js

```bash
const path = require('path');
const gluestackStyleResolver = require('@gluestack-style/babel-plugin-styled-resolver');
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
gluestackStyleResolver,
],
};
};
```

3. Just make sure your `babel.config.js` and `gluestack-style.config.js/ts` are in the same directory. We suggest you keep both of them at the root of your app codebase.
Your code gets transpiled in the build files like this.

## Advanced

Expand Down

0 comments on commit 72731ee

Please sign in to comment.