Skip to content

Commit 94aa82c

Browse files
authored
Document React support (#229)
Documents wintercms/winter#1304
1 parent abe8fc5 commit 94aa82c

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

console/asset-compilation-mix.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ php artisan mix:create <package name> [--tailwind] [--vue]
3030
By default, the `mix:create` command will only generate the basic `winter.mix.js` config file. If you would like Winter to pre-configure your package for a certain library / asset bundle, you can provide any of the following flags:
3131

3232
- `--tailwind` will configure your package for [tailwindcss](https://tailwindcss.com/)
33-
- `--vue` will configure your package for [vue.js](https://vuejs.org/)
33+
- `--vue` will configure your package for [Vue.js](https://vuejs.org/)
34+
- `--react` will configure your package for [React](https://react.dev/)
3435
- Other custom bundles can be [registered by third party plugins](asset-compilation#supported-toolset-bundles)
3536

3637
For example, the following with configure the plugin `Acme.Example` with tailwind and create `plugins/acme/example/assets/src/acme-example.css` with a tailwind setup.

console/asset-compilation-vite.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ php artisan vite:create <package name> [--tailwind] [--vue]
2121
By default, the `vite:create` command will only generate the basic `vite.config.mjs` config file. If you would like Winter to pre-configure your package for a certain library / asset bundle, you can provide any of the following flags.
2222

2323
- `--tailwind` will configure your package for [tailwindcss](https://tailwindcss.com/)
24-
- `--vue` will configure your package for [vue.js](https://vuejs.org/)
24+
- `--vue` will configure your package for [Vue.js](https://vuejs.org/)
25+
- `--react` will configure your package for [React](https://react.dev/)
2526
- Other custom bundles can be [registered by third party plugins](asset-compilation#supported-toolset-bundles)
2627

2728
For example, the following with configure the plugin `Acme.Example` with tailwind and create `plugins/acme/example/assets/src/acme-example.css` with a tailwind setup.
@@ -68,6 +69,25 @@ The helper function takes 2 arguments, the first is a `array|string` of entry pa
6869
$this->addVite(['assets/css/example.css']);
6970
```
7071
72+
### Using hot file reloading (`vite:watch`) with React
73+
74+
If you want to use hot reloading with React then you'll need to also include the [React refresh tag](https://laravel.com/docs/9.x/vite#react) prior to your scripts being loaded:
75+
76+
- In `twig`:
77+
78+
```twig
79+
{{ viteReactRefresh('theme-example') }}
80+
{{ vite(['assets/src/js/theme-example.js'], 'theme-example') }}
81+
```
82+
83+
- In `php`:
84+
85+
```php
86+
\System\Classes\Vite::reactRefreshTag('theme-example');
87+
```
88+
89+
>**NOTE:** If you are seeing `App.jsx:1 Uncaught (in promise) Error: @vitejs/plugin-react can't detect preamble. Something is wrong. See https://github.com/vitejs/vite-plugin-react/pull/11#discussion_r430879201 at App.jsx:1:26` in your developer console when running `artisan vite:watch packageName` then you are missing the React refresh tag listed above.
90+
7191
## Commands
7292
7393
### Install Node dependencies

0 commit comments

Comments
 (0)