简体   繁体   中英

How do I include css files outside static folder?

I was trying to include semantic_ui css files from folder semantic in home.html which reside in public folder. its was loading fine without server but express is not serving any .css file outside static folder. I don't want to move my files

home.html

<link rel="stylesheet" href="../semantic/out/semantic.css">

my directory structure

root-folder
    node_modules
    ...
    semantic
        out
            semantic.css
            semantic.js
        src
           ...
        tasks
           ...
        gulpfile.js
    public (static folder)
        home.html
    app.js

Express allows to use multiple static directories. From the documentation ,

To use multiple static assets directories, call the express.static middleware function multiple times:

app.use(express.static('public'))
app.use(express.static('semantic'))

Express looks up the files in the order in which you set the static directories with the express.static middleware function.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM