In a Laravel 8 / Tailwind CSS v2.1 application, I make different layouts. So in `webpack.mix.js, I have custom class files defined:
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
require("tailwindcss"),
])
.postCss('resources/css/backend.css', 'public/css', [
require("tailwindcss"),
])
.postCss('resources/css/profile.css', 'public/css', [
require("tailwindcss"),
])
.options({
processCssUrls: false,
postCss: [tailwindcss('./tailwind.config.js')],
});
backend.css and profile.css files have unique classes, but they all have some common classes in app.css. I want to define some common classes
in app.css and possibility say in backend.css to overwrite :
.admin_main_color {
@apply text-gray-300 bg-green-900;
}
which was priorly defined in common
In resources/views/layouts/backend.blade.php I added app.css (which is before of backend.css) :
<title id="app_title">{{ config('app.name', 'Laravel') }}</title>
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
<link href="{{ asset('css/backend.css') }}" rel="stylesheet">
In resources/css/app.css I have :
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
.app_main_color { // in some cases I need to possibility to overwrite class in frontend.css/backend.css
@apply text-yellow-300 bg-red-900;
}
But when I try in resources/css/backend.css :
@tailwind base;
@tailwind components;
@tailwind utilities;
@import app.css;
@layer base {
.test_class {
@apply text-gray-300 bg-red-800;
}
/*.app_main_color {*/
/* @apply text-gray-300 bg-green-900;*/
/*}*/
If to leave commented 3 lines above, I got error in the console :
(23:31) /mnt/_work_sdb8/wwwroot/lar/tAdsBack/resources/css/backend.css The `app_main_color` class does not exist. If you're sure that `app_main_color` exists, make sure that any `@import` statements are being properly processed before Tailwind CSS sees your CSS, as `@apply` can only be used for classes in the same CSS tree.
Lines with :
@import app.css;
did not help. How can I do it? I hope I clearly explained what I want...
And that will overwrite the admin_main_color definition in app.css. Can I do this, and how?
Thanks!