I have set up Laravel in a Docker container and launched it using Laravel Sail. I'm using Laravel mix with tailwind version 3 to include my CSS. The issue is that I want the entire Tailwind CSS to be compiled into my resources/css/app.css
file.
tailwind.config.js
module.exports = {
content: [
"./resources/**/*.blade.php",
"./resources/**/*.js",
"./resources/**/*.vue",
],
theme: {
extend: {},
},
plugins: [],
}
webpack.mix.js
const mix = require('laravel-mix');
mix.options({
legacyNodePolyfills: false
});
mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
require("tailwindcss"),
]);
I usually run ./vendor/bin/sail npm run watch
from my application directory within the docker container to compile resources/css/app.css.
Still, the compilation process takes a while, and the watch
command doesn't seem to catch any changes and recompile automatically. I guess it is because of my sub-optimal development environment (Intel core i3 and four GB ram).
It seems only Tailwind CSS classes contained in files in the content
key within tailwind.config.js
are compiled into resources/css/app.css
because I have to re-run ./vendor/bin/sail npm run watch
every time I make changes to my blade templates to see changes on my browser, which is cumbersome. Plus, I can't use my web browser (Google Chrome) to inspect CSS and dynamically make changes to see the effect on my browser.
I have already tried removing all files in the content
key of tailwind.config.js
i.e. content: [],
but the resulting resources/css/app.css
was almost empty; causing tailwind CSS in my blade templates not to work.
Is there a way to modify tailwind.config.js
or webpack.mix.js
so I can simply run ./vendor/bin/sail npm run dev
once, and it compiles the entire Tailwind CSS into resources/css/app.css
? I don't want to include tailwind CSS links in my HTML header.