I have a working Laravel project with Tailwind CSS
I have also used Flowbite Datepicker using CDN to include the datepicker JavaScript.
The project is working fine and the date-picker is showing nicely.
But when I run the npm run prod to minify the project the date-picker dropdown is not showing correctly.
Included the images and code.
Kindly help.
<script src="https://cdnjs.cloudflare.com/ajax/libs/flowbite/1.6.3/datepicker.min.js"></script>
<div class="relative">
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
<svg ....</svg>
</div>
<input id="date" datepicker datepicker-autohide datepicker-format="dd/mm/yyyy"
name="date" type="text" readonly="readonly" required autofocus class="form-input
shadow-outline-gray text-sm pl-10 w-full @error('date') bg-red-500 @enderror" placeholder="Select Date">
</div>
webpack.mix.js
const mix = require('laravel-mix');
mix
.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
require('postcss-import'),
require('tailwindcss'),
require('postcss-nested'),
require('autoprefixer'),
]);
if (mix.inProduction()) {
mix
.version();
}
2
Answers
As I need an urgent workaround for the production environment and found no other option other than downloading the datepicker.min.js and pasting the code under the script tag in the blade file.
Now on running "npm run prod" the CSS classes mentioned in the JS is also included while minifying.
The above workaround is Working fine.
Waiting for other better solutions. Thanks.
Of course, since the element is rendered in the DOM, the postcss and vite (laravel-mix in your case) watchers are not aware of the classes you are demanding, so in production (minified css) it will never display correctly.
try to put this above you calendar code, then, run
npm run build