Skip to content

Commit 8d57c52

Browse files
authored
Only load required frontend assets (#91)
1 parent 0453c70 commit 8d57c52

File tree

15 files changed

+183
-9164
lines changed

15 files changed

+183
-9164
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,37 @@ php please vendor:publish --tag=livewire-forms-config
2828

2929
## Manually bundling Livewire and Alpine
3030

31-
If you are [manually bundling Livewire and Alpine](https://livewire.laravel.com/docs/installation#manually-bundling-livewire-and-alpine), you will also need to import the Livewire Forms script:
31+
If you are [manually bundling Livewire and Alpine](https://livewire.laravel.com/docs/installation#manually-bundling-livewire-and-alpine), you will also need to import the Livewire Forms scripts.
32+
33+
### Full bundle
34+
35+
The `livewire-forms.js` script is the full bundle and contains all the forms logic and external libraries like Filepond.
3236

3337
```diff
3438
import { Livewire, Alpine } from '../../vendor/livewire/livewire/dist/livewire.esm';
3539
import Clipboard from '@ryangjchandler/alpine-clipboard'
36-
+ import "../../vendor/aerni/livewire-forms/resources/js/livewire-forms.js";
40+
+ import "../../vendor/aerni/livewire-forms/resources/dist/js/livewire-forms.js";
3741

3842
Alpine.plugin(Clipboard)
3943

4044
Livewire.start()
4145
```
4246

47+
### Individual imports
48+
49+
If you want more control, you may import individual scripts instead. This can be useful if you don't want to use some of the provided integrations like Filepond. At the bare minimum you should import `form.js`.
50+
51+
```diff
52+
import { Livewire, Alpine } from '../../vendor/livewire/livewire/dist/livewire.esm';
53+
import Clipboard from '@ryangjchandler/alpine-clipboard'
54+
+ import "../../vendor/aerni/livewire-forms/resources/dist/js/form.js";
55+
+ import "../../vendor/aerni/livewire-forms/resources/dist/js/filepond.js";
56+
+ import "../../vendor/aerni/livewire-forms/resources/dist/css/filepond.css";
57+
+ import "../../vendor/aerni/livewire-forms/resources/dist/js/grecaptcha.js";
58+
59+
Livewire.start()
60+
```
61+
4362
Then, add the `{{ livewire:styles }}` and `{{ livewire:scriptConfig }}` tags to your layout:
4463

4564
```html

resources/dist/js/filepond.js

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/dist/js/form.js

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/dist/js/grecaptcha.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)