3
我有一个Rails应用程序,它可以加载开发中的所有资产。Rails应用程序在生产中不使用预编译的资产
<link rel="stylesheet" href="/assets/reset.css" type="text/css" media="screen" title="no title" />
<link rel="stylesheet" href="/assets/text.css" type="text/css" media="screen" title="no title" />
<link rel="stylesheet" href="/assets/buttons.css" type="text/css" media="screen" title="no title" />
<link rel="stylesheet" href="/assets/theme-default.css" type="text/css" media="screen" title="no title" />
<link rel="stylesheet" href="/assets/login.css" type="text/css" media="screen" title="no title" />
<link rel="stylesheet" href="/assets/notify.css" type="text/css" media="screen" title="no title" />
而在生产服务器上,它仍然使用上面的代码来加载CSS。不应该使用/assets/applicaiton.css文件吗?我运行了rake资源:在生产环境中手动执行预编译任务,我可以看到它已在/ public/assets文件夹中创建了所需的文件。
那么,我需要做些什么来告诉Rails使用压缩文件?
我production.rb看起来是这样的: -
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = true
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
# Generate digests for assets URLs
config.assets.digest = true
我会尽力的,谢谢。如果我不希望生产模式压缩文件,我需要做什么?所以他们会像他们处于开发模式一样服务?这是一个后端应用程序,只有少数人会使用,所以真的不想被这些复杂问题困扰。 –