I am currently using the latest @astrojs/tailwind integration. I also installed the PrelineUI nav component which works on JavaScript injected through the PrelineUI plugin. Now the main issue is the components which uses Preline JavaScript isnt working. Eg. the hamburger menu. I tried reading and implemented all the instructions give in the docs but still couldnt make the hamburger or any other component which uses Preline JavaScript to work.
Here is the original - header nav component Here is a sample Codesandbox - Try clicking the hamburger menu or any of the dropdowns [Codesanbox link] (https://codesandbox.io/p/sandbox/gallant-wind-itec94?file=%2Ftailwind.config.cjs%3A10%2C38)
This is my tailwind.config.cjs file
/** @type {import('tailwindcss').Config} */
const preline = require('preline/plugin.js');
module.exports = {
content: [
'./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}',
'./public/**/*.astro',
'node_modules/preline/dist/*.js',
],
theme: {
extend: {},
},
plugins: [preline],
};
This is my package.json file
{
"name": "funny-orbs-2023",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/tailwind": "^3.1.2",
"@fontsource/inter": "^4.5.15",
"@fontsource/inter-tight": "^4.5.2",
"@preline/dropdown": "^1.3.0",
"astro": "^2.4.5",
"preline": "^1.8.0",
"tailwindcss": "^3.3.2"
}
}
Can somebody please help me what this issue is ?? I have been trying to figure this out for days now. Thanks in advance.
It looks like the <script>
tag in the Preline docs is incorrect:
<script is:inline src="./assets/vendor/preline/dist/preline.js"></script>
The tag does not need a is:inline
directive and the filepath does not exist.
The <script>
tag should look like this:
<script src="../../node_modules/preline/dist/preline.js"></script>
Docs: