Skip to content
Closed
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: 1 addition & 0 deletions packages/website/docs/learn/environment-setup/01-expo.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module.exports = {
require('react-strict-dom/postcss-plugin')({
include: [
// Include source files to watch for style changes
// Be specific and avoid a non-specific glob like "**/*.{js,jsx}" which could cause major performance issues during build
'src/**/*.{js,jsx,mjs,ts,tsx}',
// List any installed node_modules that include UI built with React Strict DOM
'node_modules/<package-name>/*.js'
Expand Down
5 changes: 3 additions & 2 deletions packages/website/docs/learn/environment-setup/02-next.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,19 @@ export default config;
import babelLoader from "./babelLoader.config.js";

const config = {
plugins: [
plugins: {
"react-strict-dom/postcss-plugin": {
include: [
// Include source files to watch for style changes
// Be specific and avoid a non-specific glob like "**/*.{js,jsx}" which could cause major performance issues during build
'src/**/*.{js,jsx,mjs,ts,tsx}',
// List any installed node_modules that include UI built with React Strict DOM
'node_modules/<package-name>/*.js'
],
babelConfig: babelLoader,
useLayers: true,
}
],
},
};

export default config;
Expand Down
35 changes: 30 additions & 5 deletions packages/website/docs/learn/environment-setup/03-vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,37 @@ export default {
import babelLoader from "./babel.config.js";

export default {
plugins: [
plugins: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't plugins are supposed to be an array in the postcss config?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it support both format.

"react-strict-dom/postcss-plugin": {
include: [
// Include source files to watch for style changes
// Be specific and avoid a non-specific glob like "**/*.{js,jsx}" which could cause major performance issues during build
'src/**/*.{js,jsx,mjs,ts,tsx}',
// List any installed node_modules that include UI built with React Strict DOM
'node_modules/<package-name>/*.js'
],
babelConfig: babelLoader,
useLayers: true,
},
],
},
};
```

## Vite configuration

If you just created a brand new Vite app, you might need to install

```
npm install vite-plugin-babel vite-tsconfig-paths
```

Create or edit the `vite.config.ts` file as follows.

```js title="vite.config.ts"
import { defineConfig } from "vite";
import viteBabel from "vite-plugin-babel";
import viteReact from "@vitejs/plugin-react";
import tsConfigPaths from "vite-tsconfig-paths";
import viteReact from "@vitejs/plugin-react";
import viteBabel from "vite-plugin-babel";

export default defineConfig(() => ({
plugins: [
Expand All @@ -92,7 +99,7 @@ export default defineConfig(() => ({

Your app needs to include a CSS file that contains a `@react-strict-dom` directive. This acts as a placeholder that is replaced by the generated CSS during builds.

```css title="strict.css"
```css title="src/strict.css"
/* This directive is used by the react-strict-dom postcss plugin. */
/* It is automatically replaced with generated CSS during builds. */
@react-strict-dom;
Expand All @@ -101,6 +108,8 @@ Your app needs to include a CSS file that contains a `@react-strict-dom` directi
Next, import the CSS file in the `main.tsx` file.

```js title="src/main.tsx"
// ...

// Required for CSS to work on Vite
import "./strict.css";

Expand Down Expand Up @@ -134,5 +143,21 @@ export default defineConfig(() => ({
],
},
}));
```

## TanStack Start

If you plan to use TanStack Start, you will need to adjust your vite config with the `ssr` options
Comment on lines +148 to +150

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be generalized? Presumably the Vite ssr config is not just for TanStack

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure it can, I can ajust like that

Suggested change
## TanStack Start
If you plan to use TanStack Start, you will need to adjust your vite config with the `ssr` options
## Server-Side Rendering
If you are using SSR with Vite (eg: using **TanStack Start**), you will need to adjust your vite config with the `ssr` options


```js title="vite.config.ts"
import { defineConfig } from "vite";

//...

export default defineConfig(() => ({
// ...
ssr: {
noExternal: ["react-strict-dom"],
},
}));
```