I want to install alpine js in metronic but wherever I import it, it gives error.
How to add it.
I tried
import Apline from 'alpinejs';
in plugins.js export array
'node_modules/alpinejs',
Uncaught SyntaxError: Cannot use import statement outside a module (at plugins.bundle.js:61318:1)
Also cannot do
window.Alpine = Apline;
Alpine.start():
This gives window is undefined.
How can I add alpine js in it.
in Laravel webpack
This is the simplified version.
import Alpine from "alpinejs"; window.Alpine = Alpine; Alpine.start();
mix.js('resources/mix/common/app.js', `public/assets/js/app.js`);
Run npm run dev.
Include the generated JS file starterkit\public\assets\js\app.js in your blade file.
To integrate Alpine.js into Metronic using Laravel Mix (assuming you are using Laravel and webpack), you can follow these steps:
Install Alpine.js:
Run the following command in your terminal to install Alpine.js:
npm install alpinejs mix.copy("node_modules/alpinejs/dist/alpine.js", "public/js/alpine.js"); <script src="{{ mix("js/alpine.js") }}"></script> import Alpine from "alpinejs";
window.Alpine = Alpine;
Alpine.start(); npm run dev I have installed it it runs and also included it through plugins.js file. not tried with mix.
It builds and loads script.
But the issue occur when I call
import Alpine from "alpinejs";
window.Alpine = Alpine;
Alpine.start();
it says
Uncaught SyntaxError: Cannot use import statement outside a module (at plugins.bundle.js:61318:1)
when I open webpage.
Or it says Alpine or window not defined.
I tried it in app.js file and many other. same everywhere.
laravel project.
in folders
resources/_keenthemes/*
resources/mix/*