This repository attempts to reproduce a bug when using Laravel Mix / Webpack hot reload where using new, previously unused Tailwind classes would not be rendered unless you manually refresh the page (or have used the classes before).
The culprit seems to be compiling 2 JS files, but can vary depending on project.
mix.js('resources/js/site.js', 'public/js') // <<< HMR breaks with this enabled
mix.js('resources/js/app.js', 'public/js')
After cloning the repository and opening the local directory in your terminal:
- Run
npm run dev
- Run
npm run hot
- Navigate to http://localhost:3000 in your browser
- Open
resources/js/MyComponent.vue
- Add some unused classes to
<div class="flex">
likebg-indigo-500
andtext-yellow-300
- Notice the classes are used in the HTML, but not generated in the CSS
- Open
webpack.mix.js
- Remove
mix.js('resources/js/site.js', 'public/js')
- Remove your classes in
MyComponent.vue
- Try Steps to follow again
- Notice the component is updated properly and the necessary CSS is generated and injected. Now Webpack also properly shows the CSS was reloaded in the console (not the case when the bug is active).
Adding (previously unused) classes in welcome.blade.php
seems to work fine since BrowserSync reloads the page for you.