我在生产中设置了第一个ruby站点,一切正常,但是当我运行
rake assets:precompile
它在"public/assets/"目录下添加了css/js,但是它们在文件中有路径和行号?所以只是想知道如何得到这一切在一行,没有行号/注释?我是不是错过了什么布景之类的?下面是我的application-428d86248ca363.css
的一个例子:
/* line 1, /home/joe/myapp/app/assets/stylesheets/main.scss */
body {
background: #ccc;
}
/* line 6, /home/joe/myapp/app/assets/stylesheets/main.scss */
#head {
background: #666;
}
/* line 4, /home/joe/myapp/app/assets/stylesheets/welcome.css.scss */
.block {
color: #1e1e1e;
}
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*/
你还可以看到它在末尾包含了一个大注释。我如何让它在一行中没有注释?
SCSS
它们在文件中有路径和行号
这是SCSS的一个问题,如果你使用rake assets:precompile RAILS_ENV=production
修复
在寻找参考时,我发现了这个答案和这个github:
Just to update previous answer, by Chase T.
For me this is not working anymore.
#config/compass.rb
line_comments = false
should become
line_comments = 0
考虑到资源使用compass.rb
,我看了看如何在标准的Rails应用程序中做到这一点。我发现这样做的方法是使用系统,看起来你可以使用这个命令:
#config/application.rb
config.sass.line_comments = false
这是由以下信息确认的:
使用Rails 4.1,并在看了又看(可能是误读)之后我通过将以下内容添加到
/config/environments/development.rd & production.rb
config.sass.preferred_syntax = :scss
config.sass.style = :compact
config.sass.line_comments = false
Style可以设置为:nested,:扩展、:紧凑、:压缩。你可以看到不同的选项在这里:http://sass-lang.com/documentation/file.SASS_REFERENCE.html output_style
另外,确保重新启动服务器以查看编译后的版本把
希望这能帮助到一些人。