/laravel-svelte-preset

Svelte frontend preset for Laravel.

Primary LanguagePHPMIT LicenseMIT

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:

composer require wewowweb/laravel-svelte-preset

After that, run the following command, which will provide you with the initial scaffolding of the project:

php artisan preset svelte

To install the JavaScript dependencies, run:

npm install && npm run dev

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

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        ...
    </head>
    <body>
        <!-- Include your App Component -->
        <App />

        <!-- Include the app.js file -->
        <script src="/js/app.js"></script>
    </body>
</html>

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 gal@wewowweb.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.