Skip to content

Commit 51196e1

Browse files
committed
Update Changelog and Readme
1 parent baa8ba8 commit 51196e1

2 files changed

Lines changed: 25 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## 1.1.0
8+
- Support CSS standalone file by [@imagoiq](https://github.com/imagoiq) in [#1](https://github.com/userfrosting/vite-php-twig/pull/1)
9+
- Add PHP 8.4 Tests
10+
711
## 1.0.2
812
- Apply `basePath` to server URL
913

README.md

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,30 @@ $manifest = new ViteManifest('.vite/manifest.json');
2626

2727
// Get files for `views/foo.js` entry
2828
$manifest->getScripts('views/foo.js'); // Scripts
29-
$manifest->getStyles('views/foo.js'); // Style
30-
$manifest->getImports('views/foo.js'); // Preload
29+
$manifest->getStyles('views/foo.js'); // Styles
30+
$manifest->getImports('views/foo.js'); // Preloads
3131

3232
// Render HTML tags for `views/foo.js` entry
3333
$manifest->renderScripts('views/foo.js'); // Scripts
34-
$manifest->renderStyles('views/foo.js'); // Style
35-
$manifest->renderPreloads('views/foo.js'); // Preload
34+
$manifest->renderStyles('views/foo.js'); // Styles
35+
$manifest->renderPreloads('views/foo.js'); // Preloads
3636

3737
// If you have multiple entry point scripts on the same page, you should pass them in a single call to avoid duplicates - for example:
3838
$manifest->getScripts('views/foo.js', 'views/bar.js');
3939
```
4040

41+
> [!TIP]
4142
> `ViteManifest` implements `\UserFrosting\ViteTwig\ViteManifestInterface` if you prefer to type-hint against interfaces, for use with dependency injection.
4243
4344
### Using with Twig
45+
> [!IMPORTANT]
4446
> Requires Twig 3 or newer
4547
46-
Vite writes an `manifest.json` file that contains all of the files needed for each "entry". To reference entries in Twig, you need to add the `ViteTwigExtension` extension to the Twig Environment. This accept a `ViteManifest`, which itself accept the path to the `manifest.json`,
48+
Vite writes a `manifest.json` file that contains all of the files needed for each [Rollup Input](https://rollupjs.org/configuration-options/#input) or "entry". To reference entries in Twig, you need to add the `ViteTwigExtension` extension to the Twig Environment. This accepts a `ViteManifest`, which itself accepts the path to the `manifest.json`.
4749

4850
```php
4951
use UserFrosting\ViteTwig\ViteManifest;
52+
use UserFrosting\ViteTwig\ViteTwigExtension;
5053
use Twig\Environment;
5154
use Twig\Loader\FilesystemLoader;
5255

@@ -59,7 +62,7 @@ $twig = new Environment($loader);
5962
$twig->addExtension($extension);
6063
```
6164

62-
Now, to render all of the `script` and `link` tags for a specific "entry" (e.g. `entry1`), you can:
65+
Now, to render all of the `script` and `link` tags for a specific "entry" (e.g. `views/foo.js`), you can:
6366

6467
```twig
6568
{{ vite_js('views/foo.js') }}
@@ -72,8 +75,13 @@ If you have multiple entry point scripts on the same page, you should pass them
7275
{{ vite_js('views/foo.js', 'views/bar.js') }}
7376
```
7477

75-
### Vite default port
76-
By default, vite will use port `5173`. However, if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on. Since a PHP application doesn't know which port is being used by vite, the port can be forced in the `vite.config.js` file inside your project's root directory using [`server.strictPort`](https://vitejs.dev/config/server-options#server-strictport) and [`server.port`](https://vitejs.dev/config/server-options#server-port) :
78+
Standalone CSS, SCSS, SASS, and LESS files can also be rendered directly, as long as they are defined in your Vite config as a rollup input.
79+
```twig
80+
{{ vite_css('my_theme.less') }}
81+
```
82+
83+
### Vite Default Port
84+
By default, Vite will use port `5173`. However, if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on. Since a PHP application doesn't know which port is being used by Vite, the port can be forced in the `vite.config.js` file inside your project's root directory using [`server.strictPort`](https://vitejs.dev/config/server-options#server-strictport) and [`server.port`](https://vitejs.dev/config/server-options#server-port):
7785
```js
7886
server: {
7987
strictPort: true,
@@ -90,24 +98,13 @@ $manifest = new ViteManifest(
9098
basePath: 'dist/',
9199
serverUrl: 'http://[::1]:5173/',
92100
devEnabled: true,
93-
)
101+
);
94102
```
95103

96-
`manifestPath` - string
97-
98-
Points to the Vite `manifest.json` file created for the production build.. Optional if you're using the dev server
99-
100-
`basePath` - string
101-
102-
Public base path from which Vite's published assets are served. The assets paths will be relative to the `outDir` in your vite configuration. It could also point to a CDN or other asset server, if you are serving assets from a different domain.
103-
104-
``serverUrl`` - string
105-
106-
The vite server url, including port. Can be used to specify a non-default port if used.
107-
108-
``devEnabled`` - bool
109-
110-
Indicates whether the application is running in development mode (i.e. using vite server). Defaults to false.
104+
- `manifestPath` - string: Points to the Vite `manifest.json` file created for the production build. Optional if you're using the dev server.
105+
- `basePath` - string: Public base path from which Vite's published assets are served. The assets paths will be relative to the `outDir` in your Vite configuration. It could also point to a CDN or other asset server if you are serving assets from a different domain.
106+
- `serverUrl` - string: The Vite server URL, including port. Can be used to specify a non-default port if used.
107+
- `devEnabled` - bool: Indicates whether the application is running in development mode (i.e. using Vite server). Defaults to false.
111108

112109
## See Also
113110
- [Changelog](CHANGELOG.md)

0 commit comments

Comments
 (0)