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
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,15 @@
2
2
3
3
All notable changes to this project will be documented in this file.
4
4
5
+
## 4.0.9 - 2024.03.02
6
+
### Added
7
+
* Add documentation for Craft Cloud usage with Vite ([#83](https://github.com/nystudio107/craft-vite/pull/83))
8
+
* Add support for clearing Vite caches in response to Craft Cloud's `UpController::EVENT_AFTER_UP` event ([#83](https://github.com/nystudio107/craft-vite/pull/83))
9
+
10
+
### Fixed
11
+
* Fixed an issue where the wrong CSS hash would be returned if you were using Vite 3 or earlier ([#80](https://github.com/nystudio107/craft-vite/issues/80))
12
+
* Fixed an issue where `craft.vite.entry()` would fail if you were using Vite 5 or later, due to the `ManifestHelper::fileNameWithoutHash()` function not working correctly ([#24](https://github.com/nystudio107/craft-plugin-vite/issues/24))
13
+
5
14
## 4.0.8 - 2024.01.30
6
15
### Added
7
16
* If the `devServer` is running, the `ViteService::fetch()` method will try to use the `devServerInternal` URL first, falling back on the `devServerPublic` so that `craft.vite.inline()` can pull from the `devServer` if it is running ([#22](https://github.com/nystudio107/craft-plugin-vite/issues/22))
In your `vite.config.js`, the `server.host` should to be set to `0.0.0.0`, and `server.port` set to `3000`:
@@ -501,8 +501,16 @@ JavaScript file via Twig in a `<script>` tag, you instead do:
501
501
{{ craft.vite.script("src/js/app.ts") }}
502
502
```
503
503
504
-
Note that Vite automatically also supports the direct linking to TypeScript (as in the above example), JSX, and other
505
-
files via plugins. You just link directly to them, that’s it.
504
+
Vite automatically supports the direct linking to TypeScript (as in the above example), JavaScript, JSX, and other
505
+
files formats via plugins. You just link directly to them, that’s it.
506
+
507
+
::: tip CSS is Asynchronous by default
508
+
By default, the Vite plugin will load your [CSS asynchronously](https://www.filamentgroup.com/lab/load-css-simpler/). If you are **not** using Critical CSS, you'll want to change that to avoid Flash Of Unstyled Content (FOUC) by setting the setting the second argument to `false`:
509
+
```twig
510
+
{{ craft.vite.script("src/js/app.ts", false) }}
511
+
```
512
+
See the **[Other Options](#other-options)** section below for details
513
+
:::
506
514
507
515
##### Development
508
516
@@ -586,16 +594,7 @@ import '/src/css/app.pcss';
586
594
The Vite plugin will take care of automatically generating the `<link rel="stylesheet">` tag for you in production.
587
595
588
596
By default, it loads the [CSS asynchronously](https://www.filamentgroup.com/lab/load-css-simpler/), but you can
589
-
configure this. See the **Other Options** section.
590
-
591
-
#### Polyfills
592
-
593
-
To work properly, you must also import the [Vite Polyfill](https://vitejs.dev/config/#build-polyfilldynamicimport) in
594
-
your `build.input` JavaScript file entries listed in the `vite.config.js`, for example:
595
-
596
-
```js
597
-
import"vite/dynamic-import-polyfill";
598
-
```
597
+
configure this. See the **[Other Options](#other-options)** section.
599
598
600
599
#### Legacy
601
600
@@ -911,6 +910,53 @@ So for example:
911
910
) }}
912
911
```
913
912
913
+
## Craft Cloud
914
+
915
+
During a [build](https://craftcms.com/knowledge-base/cloud-builds), Craft Cloud deploys static assets to a CDN, so you’ll need to configure the plugin to use the appropriate URLs:
Outside of Cloud, this behaves as though it were prepended with `@web`.
936
+
937
+
If you’d prefer to use an on-disk `manifestPath` when working locally (instead of a URL), the `CloudHelper::isCraftCloud()` function lets you switch based on the environment:
Additionally, your Vite config should have [public `base`](https://vitejs.dev/guide/build.html#public-base-path) set to use the same CDN URL. In Craft Cloud’s build pipeline, this is exposed as an [`CRAFT_CLOUD_ARTIFACT_BASE_URL` environment variable](https://craftcms.com/knowledge-base/cloud-builds#build-command):
0 commit comments