Download the PHP package wewowweb/laravel-svelte-preset without Composer
On this page you can find all versions of the php package wewowweb/laravel-svelte-preset. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wewowweb/laravel-svelte-preset
More information about wewowweb/laravel-svelte-preset
Files in wewowweb/laravel-svelte-preset
Package laravel-svelte-preset
Short Description Svelte frontend preset for Laravel.
License MIT
Homepage https://github.com/wewowweb/laravel-svelte-preset
Informations about the package laravel-svelte-preset
Laravel Svelte Preset
A Laravel frontend preset for initial Svelte scaffolding.
Why?
Svelte is an interesting new approach in the JavaScript space, created by @Rich_Harris. While traditional frontend frameworks do the bulk of their work in the browser, Svelte does this in compilation step. They provide a fluid syntax for writing expressive code, but compile it down to small, framework-less vanilla JavaScript.
If you don't know what Svelte is, we highly recommend starting with Rich Harris' talk Rethinking Reactivity from YGLF Code Camp 2019, his introductory blog post or - if you're more of a hands-on type - Svelte's interactive tutorial.
This package is still in active development, so you might want to watch the repository to be notified of future changes.
Installation
You can install the package via composer:
After that, run the following command, which will provide you with the initial scaffolding of the project:
To install the JavaScript dependencies, run:
The package will provide you with the initial set of files:
/js/app.js
/js/components/App.svelte
webpack.mix.js
needed to start developing with Laravel & Svelte.
Usage
Registering Custom Svelte Components
If you wish to use custom components, note you cannot use regular svelte components. Doing so will result in an invalid constructor error for the svelte component.
Please follow these general conventions when creating your custom components:
- Component name must be two or more words joined by the '-' character e.g. 'my-test-component'.
- Components can be accessed in blade file like a regular html tag e.g.
<my-test-component></my-test-component>
- Closing tag is necessary because its a web component.
If you wish to register a custom component and use it within your blade.php
files, you can do it like so:
Step 1: Create a New Custom Component
Let's create a new Svelte Component (e.g. MyTestComponent.svelte)
Step 2: Modify The webpack.mix.js
file
Modifiy the webpack.mix.js
file like so:
Step 3: Import the component to your app.js
Then within your àpp.js
file, import the MyTestComponent like so:
Step 4: Convert your App component to a custom component
Step 5: Use the new component in your blade.php
file
Additionally, you may also define the tag within your svelte component instead of with customElement.define
as so:
<svelte:options tag="my-test-component" />
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- We Wow Web
- Gal Jakic
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-svelte-preset with dependencies
illuminate/support Version ^5.8|^6.0|^7.0|^8.0|^9.0
laravel/ui Version ^1.2|^2.0|^3.0