Skip to content

Commit

Permalink
Vite v3!
Browse files Browse the repository at this point in the history
  • Loading branch information
andrefelipe committed Jul 14, 2022
1 parent 7614ae9 commit 227e7e7
Show file tree
Hide file tree
Showing 11 changed files with 393 additions and 378 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ A bare-minimum setup to serve as example to adapt to other scenarios ([WordPress

### Note about the development host

A characteristic of this setup is that you'll run your project from your own local server, for exemple http://vite-php-setup.test. Vite will be running at http://localhost:3000 where our script and styles will be served from, but accesing http://localhost:3000 directly will be empty, which is fine.
A characteristic of this setup is that you'll run your project from your own local server, for exemple http://vite-php-setup.test. Vite will be running at http://localhost:5133 where our script and styles will be served from, but accesing http://localhost:5133 directly will be empty, which is fine.

Of course, HMR and styles will work just fine! And fast!

- Mininum Node.js version >=12.0.0
- Mininum Node.js version >=14.18+

### Notes about our example code

Expand All @@ -28,7 +28,7 @@ Of course, HMR and styles will work just fine! And fast!

### Known issue 1 (during Dev only)

A limitation is Vite's port during development, PHP helpers must match the one that was created during "npm run dev" (default 3000). For example, if the port 3000 is in use, Vite will try the next one (3001 and so on), so our helper PHP wouldn't know about that.
A limitation is Vite's port during development, PHP helpers must match the one that was created during "npm run dev" (default 5173). For example, if the port 5173 is in use, Vite will try the next one (5174 and so on), so our helper PHP wouldn't know about that.

The solution is to stricly specify which port to use, and match the PHP side to the same port. Check [vite.config.js](https://github.com/andrefelipe/vite-php-setup/blob/master/vite/vite.config.js) for example.

Expand All @@ -41,6 +41,8 @@ The solution is here, adjust the paths and run in terminal:
```
ln -s {path_to_project_source}/src/assets {path_to_public_html}/assets
```
Note: this happens because our Vite code is outside the server public access, if it where, we could use [server.origin](https://vitejs.dev/config/server-options.html#server-origin) config.


### Tips for multiple entries

Expand Down
1 change: 1 addition & 0 deletions public/dist/assets/main.29a2455c.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion public/dist/assets/main.ed128c5c.js

This file was deleted.

Loading

0 comments on commit 227e7e7

Please sign in to comment.