Hello everyone,
I am struggling with setting up Laravel-mix and using a component from TailwindUIKit. When I run npm run development the required css for my page is properly compiled, but my JavaScript, and the tailwind classes within the JavaScript is not. I also tested adding the JavaScript (couple of lines of code to open and close menus) directly to my blade files, in which case the function calls from button clicks works, but the css classes still does not get compiled.
So I have 2 problems. First I do not understand why webpack is not loading the JavaScript that I added directly to my resources/js/app.js, and second how do I get the tailwind classes within the JavaScript to be compiled?
Here are my config files:
//webpack.mix.js
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')
.sourceMaps()
.options({
postCss: [
tailwindcss('./tailwind.config.js')
],
})
I noticed in my public/app.js my JavaScript code is placed inside ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
//tailwind.config.js
module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
purge: [
'./storage/framework/views/*.php',
'./resources/**/*.blade.php',
'./resources/**/*.js',
'./resources/**/*.vue',
],
}
And my resources/js/app.js. The compiled app.js is loaded in the head of my blade template <script src="{{ asset('js/app.js') }}" defer></script>
require('./bootstrap');
console.log(123);//This does show in the browser.
let icon1 = document.getElementById("icon1");
let menu1 = document.getElementById("menu1");
const showMenu1 = (flag) => {
....
....
Thank you, Reinhard.