我使用nginx为快速应用提供静态内容,这适用于服务main.css
但是main.css
是带有地图main.map.css
的已编译sass文件没有静态投放,而是返回404 GET /css/main.css.map 404
。
Nginx conf:
server {
listen 80;
# Listens to all domains
server_name _;
# Static folder location in project
root project/public;
# Reverse proxy to express app listening on port 3001
location / {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# Caching
}
我的问题是如何让node / express静态地提供.css.map
文件类型?或者有更好的方式用快递地图服务sass。
修改
解决方案是将css.map
类型添加到我的nginx缓存中,这意味着缓存的任何文件类型都不会反向代理到快速服务器,而是由nginx提供并添加了相应的缓存控件
# cache.appcache, HTML and Data
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
add_header Access-Control-Allow-Origin *;
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|css.map|js)$ { # Added map.css filetype
expires 1y;
access_log off;
}
# WebFonts
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
expires 1M;
access_log off;
}
感谢。