css - 如何让rails asset pipeline编译coffee脚本和scss文件?

标签 css ruby-on-rails ruby asset-pipeline

这可能以前有人问过。我已经通过一些解决方案搜索了堆栈溢出。我试图用很少的东西来实现那些:)。我卡住了。请帮忙。我是 Rails 的新手

我在 assts 文件夹中有几个 scss 文件,如下所示

assets
    javascript
       application.js
       create.js.coffee
       help.js.coffee
    images

    stylesheets
       application.css
       create.css.scss
       forms.css.scss
       help.css.scss

我需要的是在 ruby​​ Assets 管道中编译这些文件,这样它就可以编译然后组合,以便显示样式和脚本,而这在我的网站上没有显示。

在我的 application.js 中

// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .

在 application.css 中,我有

/*
 * This is a manifest file that'll automatically include all the stylesheets available in this directory
 * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
 * the top of the compiled file, but it's generally better to create a new file per style scope.
 *= require_self
 *= require_tree .
 *= require 'site'
*/

此外,在 production.db 中我有

  # 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

请帮助编译。有什么想法吗?

最佳答案

您必须在 Assets 预编译之前设置 RAILS_ENV 值,因为默认情况下 RAILS_ENV 等于“开发”,但您需要设置“生产”。试试这个:

RAILS_ENV=production bundle exec rake assets:precompile

关于css - 如何让rails asset pipeline编译coffee脚本和scss文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26520492/

相关文章:

html - 我怎样才能让我的深蓝色下拉背景不透明

Javascript - 如何突出显示最后单击的列表项

ruby - 中间人服务器只是在 Windows 8 上用文件观察器停止

html - 居中 Div 左对齐文本

javascript - 当我点击另一个元素时隐藏一个元素

mysql - 如何通过sql查询有效检查记录是否存在?

ruby-on-rails - Ruby on Rails - 路由 - 跳出 URL

ruby-on-rails - Hirb 在 Rails 控制台中根本不起作用

windows - 在 Windows 上启动 Sinatra 应用程序时,shotgun gem 会爆炸

ruby - 使用数组作为 ruby​​ 哈希键的用例