Importing old project pages onto filament pages
Last year I made fully working Laravel project but it was not using filament. Now project is being continued on and my original project needs to be re-added through filament. I am making filament pages and linking them with same options as my old routes and then I comment off route for it so it goes trought filament panel like building/announcements. Page renders and some of things do work, but certain css and js wont load in. I am not sure if this is correct way of merging old project pages into filament pages
44 Replies
Hard to tell. As always it depends on the project. If CSS/JS won't load that probably was included in a stack or in the layout and not readded through Filament
it is tailwind so most of css is within view file. For example there is this tag and it uses bg-red-900 but it just wont work but bg-red-500 does work. Same was with bg-green-900 but bg-green-800 did work while bg-red-800 didnt work so I wonder if filament just forbids certain colors and other tailwind elements or just overrides them somehow
if you made custom views and components you need to add their path to the tailwind config for filament to recognize and compile the classes
Sounds like you don’t have a custom Filament theme then.
I found preset and safelist but with commenting it off nothing much changes. I also imported all content entries and added
because only external css classes I used were all placed in resources/css/app.css and I copied them all to this project at same file. this is edited tailwind.config.js
You registed your custom theme via
viteTheme and compiled it?I dont use custom theme
Then that's your issue. You need a custom theme.
just make one always anyway even if you don't need it at the beginning, you are gonna need it eventually for a plugin or something else
but filament page only render style from themes?
What?
I can't follow.
If you want to use Tailwind CSS you need to compile a CSS file to include those classes – that's a "theme" in Filament terms.
but what if most of my CSS is within blade files
I need to move it all to theme?
As
<style> tags? That doesn't matter. If they are included inline it should work the same way as before.
like this
That is not CSS, that's Tailwind.
And Tailwind requires a compilation step where it scans your files for the used classes and creates a CSS file that only includes classes you used.
i think there's underlying confusion on how tailwind works as a whole compared to something like bootstrap
it was like npm run dev or something right
because I would still edit tailwind live I wouldnt rebuild after each change
not sure if how i could explain is 100% correct but practically:
- bootstrap or similar: gives you a premade set of css classes which you import and use directly on the html
- tailwind : you define the classes in the html and tailwind reads from its config and compile the classes it finds applying the properties defined in the configuration
from the tailwind.config.js file you can do a lot of things: define new classes with styles preapplied, change name of the classes themselves while maintaining their configurated styles, add more colors which will then applied to all utility classes automatically, etc
the reason some your styles worked and some didn't was because filament used some of those classes already and had tailwind compile them
so I need to move everthing custom into single theme file? I can see in Provider that I use that theme is already made
What do you mean by "move"? You need to create a theme. And that theme needs to be configured via
tailwind.config.js to scan the folders that use TailwindCSS.I can see that theme was already made
https://i.imgur.com/OFjwRma.png
and main tailwind.config.js also links to it
And the
tailwind.config.js contains all the correct paths?
There's a separate tailwind.config.js for the theme. Not the main oneyeah the main one outside this folder
No, it needs to be the one that belongs to the theme
Tailwind doens't care about your CSS file. It cares about your PHP and Blade files which contains Tailwind CSS
yeah I linked them too copied paths from my old project
linked all views
In
resources/css/filament/building/tailwind.config.js?no it was linked in global one I will link it here too
your tailwind.config.js inside the building folder would look something like this

in the content array is where you define the paths to your blade files so that then your custom theme can recognize them properly and apply them to filament
yeah I was doing it I just was using the global one
The global one is not relevant to us. Please ignore this for now,
Solution
now that I am using one with theme it is working I think
I also moved all my custom theme from app.css to theme.css
I just dont know if I am linking too many things
it's whatever really, on deploy it's gonna precompile them
We don't know it either. You need to link all the files that contain TailwindCSS.
in the context of filament i don't think you would need vue files tho
Unless he wants to include Vue components inside Filament.
i vaguely remember a library for that existing but i don't remember the name, neither if it's actually supported
You mean MingleJS. You can use Full-Page components on a page easily without it.
I think MingleJS is for making it work inside reactive Livewire components
aren't all filament pages livewire components at base
thanks for help I was stuck on this for 2 days
They are. But they don’t need to be reactive. The can also just render a Vue component and never update like plain old Blade