I have a basic Node.JS server setup as I'm doing a new project for work. I've written and optimizer function that strips unnecessary things like tabs, newlines and comments from HTML, JavaScript and CSS.
For some odd reason when I added my <link type="text/css" href="/css/bootstrap.mins.css">
to my head it's not loading or showing up in the Google Network tab.
The main HTML is loading just not the CSS.
Server:
app.get("/css/:file",function(req,res){
logger.log("CSS File");
res.writeHead(200, {"Content-Type": "text/css"});
res.write(fs.readFileSync(appRoot + "/css/" + req.params.file,"utf8").optimize());
res.end();
});
There is no nested CSS files, all in one directory. This, in theory, should work but it isn't. It loads and is processed when I go to the direct URL. Just not from the LINK .
Okay, after further study I found that my code above did work. I had 1 slight failure though. I missed the rel
tag in the actual link. The CSS loads fine and optimized after this.
<head>
<title>In House Tool</title>
<link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
</head>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.