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

Add react-strict-dom/postcss-plugin #282

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion apps/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"expo": "^52.0.6",
"expo-build-properties": "~0.13.1",
"expo-status-bar": "~2.0.0",
"postcss-react-strict-dom": "^0.0.5",
"react": "~18.3.1",
"react-dom": "~18.3.1",
"react-native": "~0.76.1",
Expand Down
10 changes: 5 additions & 5 deletions apps/examples/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*/

module.exports = {
plugins: {
'postcss-react-strict-dom': {
plugins: [
require('react-strict-dom/postcss-plugin')({
include: ['src/**/*.{js,jsx,mjs,ts,tsx}']
},
autoprefixer: {}
}
}),
require('autoprefixer')
]
};
6 changes: 0 additions & 6 deletions apps/website/docs/learn/01-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ For web support, please make sure the following peer dependencies are installed:
npm install react react-dom
```

Extracting styles to static CSS requires the following PostCSS plugin:

```
npm install --save-dev postcss-react-strict-dom
```

### Native

For native support, please make sure the following peer dependencies are installed (note that using the new React Native architecture is required):
Expand Down
26 changes: 14 additions & 12 deletions apps/website/docs/learn/02-environment-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,36 @@ module.exports = function (api) {
// Expo's babel preset
'babel-preset-expo',
// React Strict DOM's babel preset
[reactStrictPreset, {
debug: dev,
dev,
platform
}]
[
reactStrictPreset,
{
debug: dev,
dev,
platform
}
]
]
};
};
```

## PostCSS configuration

[PostCSS](https://postcss.org/) is a tool for generating CSS. It's enabled by default in Expo and it's the recommended way to extract React Strict DOM styles to static CSS for web builds. Once the [postcss-react-strict-dom](https://github.com/javascripter/postcss-react-strict-dom) plugin is installed, it can be used to extract styles. Create a `postcss.config.js` file as follows.
[PostCSS](https://postcss.org/) is a tool for generating CSS. It's enabled by default in Expo and it's the recommended way to extract React Strict DOM styles to static CSS for web builds. `react-strict-dom/postcss-plugin` can be used to extract styles. Create a `postcss.config.js` file as follows.

```js title="postcss.config.js"
module.exports = {
plugins: {
'postcss-react-strict-dom': {
plugins: [
require('react-strict-dom/postcss-plugin')({
include: [
// Include source files to watch for style changes
'src/**/*.{js,jsx,mjs,ts,tsx}',
// List any installed node_modules that include UI built with React Strict DOM
'node_modules/<package-name>/*.js'
]
},
autoprefixer: {}
}
}),
require('autoprefixer')
]
};
```

Expand Down Expand Up @@ -122,7 +125,6 @@ Your app needs to include a CSS file that contains a `@stylex` directive. This a

Next, import the CSS file in the entry file of your app.


```js title="index.js"
// Required for CSS to work on Expo Web.
import './stylex.css';
Expand Down
Loading