You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: UPGRADE.md
+31-11Lines changed: 31 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,10 @@ import laravel from 'laravel-vite-plugin'
34
34
35
35
exportdefaultdefineConfig({
36
36
plugins: [
37
-
laravel(),
37
+
laravel([
38
+
'resources/css/app.css',
39
+
'resources/js/app.js',
40
+
]),
38
41
// react(),
39
42
// vue({
40
43
// template: {
@@ -48,7 +51,7 @@ export default defineConfig({
48
51
})
49
52
```
50
53
51
-
If your entry point is not `resources/js/app.js`, you should read the [entry point docs](https://github.com/laravel/vite-plugin/blob/docs/docs/vite.md#entry-points) to learn how to configure the Laravel plugin for your project.
54
+
If you are building an SPA, you will get a better developer experience by removing the CSS entry point above and [importing your CSS from Javascript](#importing-your-css-from-your-javascript-entry-points).
52
55
53
56
### Update NPM Scripts
54
57
@@ -116,14 +119,17 @@ You will also need to update these references in your JavaScript code to use the
### Import your CSS from your JavaScript entry point(s)
122
+
### Importing your CSS from your JavaScript entry point(s)
120
123
121
-
Vite expects your CSS files to be imported via JavaScript, such as your `resources/js/app.js` entry point:
124
+
If you are building an SPA, you will get a better experience by importing your CSS from your JavaScript entry point(s), such as your `resources/js/app.js` entry point:
122
125
123
-
```js
124
-
import'../css/app.css'
126
+
```diff
127
+
import './bootstrap';
128
+
+ import '../css/app.css';
125
129
```
126
130
131
+
In development mode, Vite will automatically inject your CSS into the page. In production, a dedicated stylesheet will be generated that the `@vite` directive will load from the manifest.
132
+
127
133
### Replace `mix()` with `@vite`
128
134
129
135
When using Vite, you will need to use the `@vite` Blade directive instead of the `mix()` helper.
@@ -133,18 +139,18 @@ This will automatically detect whether you are running in serve or build mode an
If your entry point is not `resources/js/app.js`, you should read the [entry point docs](https://github.com/laravel/vite-plugin/blob/docs/docs/vite.md#entry-points) to learn how to use the `@vite` directive with different entry points.
145
+
The entry points should match those used in your `vite.config.js`.
140
146
141
147
#### React
142
148
143
149
If you are using React and hot-module replacement, you will need to include an additional directive *before* the `@vite` directive:
144
150
145
151
```html
146
152
@viteReactRefresh
147
-
@vite
153
+
@vite('resources/js/app.jsx')
148
154
```
149
155
150
156
This loads a React "refresh runtime" in development mode only, which is required for hot module replacement to work correctly.
@@ -212,7 +218,21 @@ You may remove your dedicated Laravel Mix SSR configuration:
212
218
rm webpack.ssr.mix.js
213
219
```
214
220
215
-
In most cases you won't need a dedicated SSR configuration file with Vite. If your SSR entry point is not `resources/js/ssr.js`, you should read the [entry point docs](https://github.com/laravel/vite-plugin/blob/docs/docs/vite.md#entry-points) to learn how to configure the Laravel plugin for your project.
221
+
In most cases you won't need a dedicated SSR configuration file with Vite. You can specify your SSR entry point by passing a configuration option to the Laravel plugin.
222
+
223
+
```js
224
+
import { defineConfig } from'vite'
225
+
importlaravelfrom'laravel-vite-plugin'
226
+
227
+
exportdefaultdefineConfig({
228
+
plugins: [
229
+
laravel({
230
+
input:'resources/js/app.js',
231
+
ssr:'resources/js/ssr.js',
232
+
}),
233
+
],
234
+
})
235
+
```
216
236
217
237
You may wish to add the following additional scripts to your `package.json`:
218
238
@@ -342,7 +362,7 @@ You will need to replace the `@vite` Blade directive with `<script>` and `<link
0 commit comments