Answer the question
In order to leave comments, you need to log in
How to include css file in express (node js)?
Hello. I am trying to include app.component.css file. Unfortunately, it doesn't work. Can you advise something?
server.js
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var index = require('./routes/index');
var tasks = require('./routes/tasks');
var port = 3000;
var app = express();
//View Engine
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.engine('html', require('ejs').renderFile);
// Set Static Folder
app.use(express.static(path.join(__dirname, 'client')));
// Body ParseMW
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use('/', index);
app.use('/api', tasks);
app.listen(port, function(){
console.log('Server started on port '+port);
});
<header>
<link rel="stylesheet" type="text/css" href="/app.component.css" />
</header>
import {Component} from '@angular/core';
@Component (
{
moduleId:module.id,
selector: 'app',
templateUrl: 'app.component.html',
styleUrls:['app.component.css']
}
)
export class AppComponent { }
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question