为什么在生产中获取空CSS文件? [英] Why getting empty CSS files in Production?

查看:94
本文介绍了为什么在生产中获取空CSS文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文件 active_admin.css.scss 中放置了许多CSS文件:

I had put many css files in the file active_admin.css.scss :

// Active Admin's got SASS!
@import "active_admin/mixins";
@import "active_admin/base";
@import "admin/plugins/*";
@import "admin/calendar";
@import "jquery-ui.css";
@import "admin/jquery.datepick.css";

但是文件"jquery-ui.css""admin/jquery.datepick.css"造成了问题.我在以下浏览器控制台中收到 404 Not Found 错误:

But the files "jquery-ui.css" and "admin/jquery.datepick.css" are creating problems. I am getting the 404 Not Found error in the browser console for below :

http://staging.xxx.com/assets/jquery-ui.css
http://staging.xxx.com/assets/admin/jquery.datepick.css

我还检查了浏览器中的资产,这两个文件存在,但其中没有内容.我在Ec2中使用Nginx作为我的Web服务器.所有人都在开发中,但不在生产中.

I also checked the assets in browsers, these 2 files are present, but they don't have content inside it. I am using Nginx as my webserver in Ec2. All is working in development, but not in production.

我的Ngnix的配置如此答案所述.我正在使用Capistrano进行部署.一切正常,但那两个文件却没有.

My Ngnix is configured as mentioned in this answer. I am using Capistrano to deploy. Everything is working but not those 2 files.

我在 production.rb 中也有以下设置:

config.assets.compile = true
config.assets.precompile += %w[active_admin.css active_admin.js]

仍然没有用.我从此处找到了上述建议.

And still it didn't work. I found the above suggestion from here.

推荐答案

摆脱@import声明中的文件扩展名.应该是:

Get rid of the file extensions in your @import declarations. It should be:

@import "jquery-ui";
@import "admin/jquery.datepick";

这篇关于为什么在生产中获取空CSS文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆