Key Concepts:
-
Guna Remix
-
Remix ada benda dipanggil
links
export -
Beza guna daripada usual React way basically
-
Links are route-based rather than component-based
-
Links are automatically managed (added/removed) based on route activity
-
More granular control over resource loading
-
Granular means instead of loading all the CSS for your app at once, Remix only loads the styles needed for the specific part of the app. Just imagine you have a book with 100 chapters, and you only read Chapter 5. Granular loading is like opening just Chapter 5 instead of carrying the whole book with you. It makes things faster and lighter!
-
-
Why This Matters for React Dev yg guna Remix:
-
Mental Model Shift → Instead of thinking about styles at the component level (macam in React), Remix encourages thinking about styles at the route level
-
Basically wit this way better performance as styles are loaded/unloaded with routes
-
-
Common Pitfalls to Avoid:
-
Don’t think about styles as just component-level concerns
-
Jgn assume all styles need to be globally available
-
Remember that route-based styling can affect how you structure your CSS
-
Problem 1 : Links to Public Files
So the issue above is
-
Initially the SVG color is black
-
So I update the color svg with original code color and saved the file
-
However the favicon not being updated, this is bc when updating static assets browsers cache them based on
cache-control headers
-
This is error-prone and requires manual intervention so it is tedious
Solution
-
I moved the
favicon.svg
fromapp/public
folder toapp/assets
-
Import the assets to the
root.tsx
accordingly and replacehref
fromhref: '/favicon.svg'
tohref: {imported name asset}
What I did not know
Asset Fingerprinting:
|
|
What is Asset Fingerprinting?
- It’s a technique where a file’s name includes a hash based on its contents (refer image above can see the hash is happening every time I update my SVG icon WITHOUT hard refresh)
Why It Matters:
|
|
How It Works in Different Frameworks:
|
|
Why This Matters:
-
Cache Optimization
-
Browsers can cache aggressively (1 year+)
-
Cache automatically invalidates when content changes
-
No manual cache busting needed
-
-
Development Experience
-
No manual version management
-
Automatic updates when files change
-
Common Gotchas:
- Don’t mix approaches:
|
|
- Directory Structure:
|
|
This pattern works across modern web development - the implementation details might differ between frameworks, but the concept of asset fingerprinting for cache optimization is universal.
Problem 2 : Compiling CSS
PostCSS and Tailwind CSS configuration is part of this section
It basically asked you to created
-
postcss.config.js
-
tailwind.css
-
tailwind.config.ts
I never care about
postcss
andautoprefixer
for god knows who even cares what even do lol but it does thing
Whutdaheck is PostCSS
Postcss is like swiss army knives
- What PostCSS Actually Is:
|
|
-
Core Functions:
-
Transforms modern CSS into browser-compatible CSS
-
Adds vendor prefixes automatically
-
Enables CSS nesting and modern features
-
Works as a platform for plugins (like Tailwind)
-
Why We Need It:
|
|
The relationship in Remix:
|
|
Simply means it works like a pipeline:
-
I write Tailwind classes
-
Then PostCSS processes them
-
So Browser gets optimized (minify version) CSS
Real-World Example**
|
|
Autoprefixer is like a translator that makes your CSS work across different browsers. Here’s what it does:
|
|
Why Autoprefixer
Matters
-
Browser Compatibility
- Without
Autoprefixer
→ CSS might work on Google Chrome but breaks Safari (ofc its safari)
- Without
|
|
Smart Processing
-
Only adds prefixes when needed
-
Removes outdated prefixes
|
|
Why This Process Matters:
-
Consistent output across different environments
-
Optimized for production
-
Maintainable development experience
Common Gotchas:
- Plugin Order Matters
|
|
Though according to PostCSS creator Andrey Sitnik ,
Order doesn’t matter in PostCSS 8 since plugins run simultaneously'
The current file’s configuration follows these best practices with postcss-import first, followed by nesting support, Tailwind, and finally Autoprefixer
.