Upon joining a new project, I noticed an interesting method for importing stylesheets. Instead of the usual HTML linking method, the stylesheet is imported into each page's JS file like this:
import "../../style.css";
Usually, CSS stylesheets are linked in HTML files as shown below:
<head>
<link rel="stylesheet" href="styles.css">
</head>
This project utilizes Javascript/jQuery and Vite.js instead of Webpack. Upon inspecting the Vite documentation, I observed that the example projects utilize CSS @import without specifying why.
Is there a specific reason for importing the stylesheet into JS files rather than linking it to HTML files? Or vice versa? I am seeking information regarding any best practices or potential advantages/disadvantages associated with each approach, rather than personal opinions.