Skip to content

Commit ac036e2

Browse files
committed
feat: Add alpine.js
At this this, alpine is only loaded in when on a admin route
1 parent d52915c commit ac036e2

File tree

6 files changed

+83
-30
lines changed

6 files changed

+83
-30
lines changed

package-lock.json

+54
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
"tinymce": "^5.10.2"
4747
},
4848
"dependencies": {
49+
"alpinejs": "^3.7.1",
4950
"bootswatch": "^4.6.1",
51+
"flatpickr": "^4.6.9",
5052
"sweetalert2": "^11.1.9"
5153
},
5254
"version": "2.4.0",

resources/js/alpine.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Alpine from 'alpinejs';
2+
3+
window.Alpine = Alpine;
4+
5+
Alpine.start();

resources/js/app.js

-16
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,3 @@ tinymce.init({
2929
selector: 'textarea.tinymce',
3030
plugins: ['code', 'paste', 'link']
3131
});
32-
33-
// window.Vue = require('vue');
34-
// import VueSweetalert2 from 'vue-sweetalert2';
35-
// Vue.use(VueSweetalert2);
36-
37-
/**
38-
* Next, we will create a fresh Vue application instance and attach it to
39-
* the page. Then, you may begin adding components to this application
40-
* or customize the JavaScript scaffolding to fit your unique needs.
41-
*/
42-
43-
// Vue.component('example-component', require('./components/ExampleComponent.vue'));
44-
//
45-
// const app = new Vue({
46-
// el: '#app'
47-
// });

resources/views/layouts/app.blade.php

+21-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE html>
22
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
3+
34
<head>
45
<meta charset="utf-8">
56
<meta http-equiv="X-UA-Compatible" content="IE=edge">
@@ -18,20 +19,25 @@
1819
<!-- Styles -->
1920
<link href="{{ mix('css/app.css') }}" rel="stylesheet">
2021

22+
@livewireStyles
23+
2124
<!-- Robots -->
22-
<meta name="robots" content="noindex"/>
25+
<meta name="robots" content="noindex" />
2326

2427
<!-- Scripts -->
2528
<script src="{{ mix('js/manifest.js') }}"></script>
2629
<script src="{{ mix('js/vendor.js') }}"></script>
2730
<script src="{{ mix('js/app.js') }}"></script>
28-
@livewireStyles
31+
@if (request()->routeIs('admin*'))
32+
<script src="{{ mix('js/alpine.js') }}" defer></script>
33+
@endif
2934
</head>
35+
3036
<body>
31-
<div id="app">
32-
@include('layouts.navbar')
33-
<main class="py-4">
34-
<div class="container">
37+
<div id="app">
38+
@include('layouts.navbar')
39+
<main class="py-4">
40+
<div class="container">
3541

3642
<ol class="breadcrumb">
3743
@foreach (Breadcrumbs::current() as $crumbs)
@@ -47,13 +53,14 @@
4753
@endforeach
4854
</ol>
4955

50-
@yield('content')
51-
@include('layouts.footer')
52-
</div>
53-
</main>
54-
</div>
55-
<!-- Scripts -->
56-
@stack('scripts')
57-
@livewireScripts
56+
@yield('content')
57+
@include('layouts.footer')
58+
</div>
59+
</main>
60+
</div>
61+
<!-- Scripts -->
62+
@stack('scripts')
63+
@livewireScripts
5864
</body>
65+
5966
</html>

webpack.mix.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require('laravel-mix-purgecss');
1616
require('dotenv').config();
1717

1818
mix.js('resources/js/app.js', 'public/js')
19+
.js('resources/js/alpine.js', 'public/js')
1920
.sass('resources/sass/app.scss', 'public/css', {
2021
additionalData: '$envColorPrimary: ' + (process.env.BOOTSTRAP_COLOR_PRIMARY || '#2C3E50') + '; $envColorSecondary: ' + (process.env.BOOTSTRAP_COLOR_SECONDARY || '#95a5a6') + '; $envColorTertiary: ' + (process.env.BOOTSTRAP_COLOR_TERTIARY || '#18BC9C') + '; $envColorSuccess: ' + (process.env.BOOTSTRAP_COLOR_SUCCESS || '#18BC9C') + '; $envColorWarning: ' + (process.env.BOOTSTRAP_COLOR_WARNING || '#F39C12') + '; $envColorDanger: ' + (process.env.BOOTSTRAP_COLOR_DANGER || '#E74C3C') + ';'
2122
})

0 commit comments

Comments
 (0)