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: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
5
5
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).
6
6
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)
> `ViteManifest` implements `\UserFrosting\ViteTwig\ViteManifestInterface` if you prefer to type-hint against interfaces, for use with dependency injection.
42
43
43
44
### Using with Twig
45
+
> [!IMPORTANT]
44
46
> Requires Twig 3 or newer
45
47
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`.
47
49
48
50
```php
49
51
use UserFrosting\ViteTwig\ViteManifest;
52
+
use UserFrosting\ViteTwig\ViteTwigExtension;
50
53
use Twig\Environment;
51
54
use Twig\Loader\FilesystemLoader;
52
55
@@ -59,7 +62,7 @@ $twig = new Environment($loader);
59
62
$twig->addExtension($extension);
60
63
```
61
64
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:
63
66
64
67
```twig
65
68
{{ vite_js('views/foo.js') }}
@@ -72,8 +75,13 @@ If you have multiple entry point scripts on the same page, you should pass them
72
75
{{ vite_js('views/foo.js', 'views/bar.js') }}
73
76
```
74
77
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):
77
85
```js
78
86
server: {
79
87
strictPort:true,
@@ -90,24 +98,13 @@ $manifest = new ViteManifest(
90
98
basePath: 'dist/',
91
99
serverUrl: 'http://[::1]:5173/',
92
100
devEnabled: true,
93
-
)
101
+
);
94
102
```
95
103
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.
0 commit comments