I'm moving to Vite from MIx. Vite appears to be working as it recognises changes in my JS code and reports errors if a file does not exist.
However, I can not get my Blade views to function with my own JS scripts. Other portions of the page which rely on JQuery are working.
Furthermore, when I run a test to see if JQuery is working I get a positive result.
<script>
window.onload = function() {
if (window.jQuery) {
// jQuery is loaded
alert("Yeah!");
} else {
// jQuery is not loaded
alert("Doesn't Work");
}
}
</script>
Chrome Dev Tools confirms that my JS files are loaded with a a status of 200.
Here is my set up
Master Layout File Header
@vite(['resources/css/app.css', 'resources/js/bootstrap.js']). // This is Laravel Bootstrap
Vite Config
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/app.css',
'resources/js/bootstrap.js' // This is Laravel Bootstrap
],
refresh: true,
}),
],
});
Laravel Bootstrap
import _ from 'lodash';
window._ = _;
import 'bootstrap/dist/js/bootstrap.js';
import 'bootstrap/js/dist/popover.js';
import './quotations.js'
import './functions.js'
import './hashtable.js'
Many Thanks!!