Basic functionality

This commit is contained in:
2022-03-12 16:25:30 +01:00
parent f3beaa64cf
commit acc21b7b24
137 changed files with 12647 additions and 5089 deletions

View File

@@ -1,5 +1,4 @@
Nette Vite
=================
# Nette Vite
This is a simple, skeleton application using the [Nette](https://nette.org). This is meant to
be used as a starting point for your new projects.
@@ -12,46 +11,41 @@ If you like Nette, **[please make a donation now](https://nette.org/donate)**.
In addition, this skeleton provides complete solution for fast, compelling applications with a minimal amount of effort.
* [Vite](https://vitejs.dev/) - next generation frontend tooling
* [Tailwind 3+](https://tailwindcss.com/) - a utility-first CSS framework packed with classes
* [Stimulus 3+](https://stimulus.hotwired.dev/) - designed to augment your HTML with just enough behavior to make it shine
* [Turbo 7+](https://turbo.hotwired.dev/) - accelerates links and form submissions by negating the need for full page reloads
- [Vite](https://vitejs.dev/) - next generation frontend tooling
- [Tailwind 3+](https://tailwindcss.com/) - a utility-first CSS framework packed with classes
- [Stimulus 3+](https://stimulus.hotwired.dev/) - designed to augment your HTML with just enough behavior to make it shine
- [Turbo 7+](https://turbo.hotwired.dev/) - accelerates links and form submissions by negating the need for full page reloads
Requirements
------------
## Requirements
- PHP 8.0
- Node.js LTS
- Docker
Local Setup
------------
## Local Setup
The best way to install Web Project locally is using Docker. If you don't have Docker yet,
download it following [the instructions](https://www.docker.com/products/docker-desktop).
download it following [the instructions](https://www.docker.com/products/docker-desktop).
Use following commands:
mkdir nette-vite && cd nette-vite
git clone --depth 1 https://github.com/evromalarkey/nette-vite.git . && npm i
git clone --depth 1 https://github.com/evromalarkey/nette-vite.git . && npm i
That downloads the project from Github, installs `package.json` dependencies. After that you can serve your project from localhost
docker compose up
docker compose up
npm run dev
Then visit `http://localhost` in your browser to see the welcome page.
JS and CSS files are served via Vite, directly from sources. Any file changes reloads the browsers for fast local development.
> On Windows it's recommended to use **WSL2** to run everything (Docker, Node.js via nvm), it's the best approach. Otherwise, some docker scripts inside package.json would work only in PowerShell.
> On Windows it's recommended to use **WSL2** to run everything (Docker, Node.js via nvm), it's the best approach. Otherwise, some docker scripts inside package.json would work only in PowerShell.
> When correct Node.js version is set in **PhpStorm** (WSL2 on Windows), you can use build-in npm to install dependencies or run scripts via GUI.
Production Setup
----------------
## Production Setup
Make directories `temp/` and `log/` writable.
@@ -61,16 +55,18 @@ should be ready to go.
**It is CRITICAL that whole `app/`, `config/`, `log/` and `temp/` directories are not accessible directly
via a web browser. See [security warning](https://nette.org/security-warning).**
Vite
----------------
## Vite
There are few possible ways how to load assets with Vite in your latte templates.
Option 1 - print all `<script>` and `<link>` tags automatically, with this you have to include css in `.js`
```latte
{$vite->printTags('src/scripts/main.js')}
```
Option 2 - same as first option, but you have more control over your HTML
```latte
{if $vite->isEnabled()}
<script type="module" src="{='@vite/client'|asset}"></script>
@@ -84,6 +80,7 @@ Option 2 - same as first option, but you have more control over your HTML
```
Option 3 - most basic, but currently not possible for production, due Vite drawback - [vitejs/vite#6595](https://github.com/vitejs/vite/issues/6595)
```latte
{if $vite->isEnabled()}
<script type="module" src="{='@vite/client'|asset}"></script>