using the express.static middleware in an Express app.
Serve static content for the app from the “public” directory in the application directory:
index.js
// GET /style.css etc app.use(express.static(path.join(__dirname, 'public')))
在工程目录下新建一个public文件夹,该文件夹下放static contents, like app.css, app.js, etc.
app.css
body{ background-color: pink; }
在对应的ejs文件下添加依赖:
<link rel="stylesheet" href="/app.css">