gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 12:45:57 24 4
gpt4 key购买 nike

这可能以前有人问过。我已经通过一些解决方案搜索了堆栈溢出。我试图用很少的东西来实现那些:)。我卡住了。请帮忙。我是 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com