【发布时间】:2020-10-09 22:24:01
【问题描述】:
我有一个前端反应应用程序,在使用 npm run build 后,它会创建构建文件夹:
- 构建
- favicon.ico
- index.html
service-woker.js- 静态
使用django的python manage.py collectstatic后发现django的做法是只拉出静态文件夹,favicon.ico没有拉出。所以,我的网站图标不起作用。
在我的 index.html 中,<link rel="apple-touch-icon" href="%PUBLIC_URL%/favicon.ico" />
在我的 settings.py 中
STATICFILES_DIRS = [
os.path.join(BASE_DIR, '../frontend/build/static')
]
STATIC_ROOT = '/var/www/web/home/static/'
STATIC_URL = 'home/static/'
在 chrome 中检查 headers 元素:
<link rel="icon" href="./home/favicon.ico">
如何让它显示我的网络图标。谢谢!
【问题讨论】:
-
你的静态设置怎么样-> docs.djangoproject.com/en/3.1/howto/static-files
-
@iklinac 添加了 settings.py
-
如何在生产环境中提供文件
标签: django favicon collectstatic npm-build