我们升级到sass-rails版本5.0.0并获得此弃用警告:
DEPRECATION WARNING: Extra .css in SCSS file is unnecessary. Rename /Users/foo/Projects/foo/app/assets/stylesheets/foo.css.scss to /Users/foo/Projects/foo/app/assets/stylesheets/foo.scss. (called from _app_views_layouts_application_html_erb__1560597815210891605_70190441246060 at /Users/foo/Projects/foo/app/views/layouts/application.html.erb:13)
任何人都知道这是怎么回事? gem是否真的希望我重命名我的所有样式表资源:
app/assets/stylesheets/foo.css.scss
为:
app/assets/stylesheets/foo.scss
似乎对我来说违背了多年的Rails惯例。也许有办法抑制弃用警告?
答案 0 :(得分:29)
这为我处理了这个问题:
#!/bin/sh
for file in $(find ./app/assets/stylesheets/ -name "*.css.scss")
do
git mv $file `echo $file | sed s/\.css//`
done
答案 1 :(得分:13)
是的,您需要将.css.scss
重命名为.scss
,因为链轮4中不支持.css.scss
。
如果您想暂时禁止弃用,可以执行以下config/initializer/deprecations.rb
Rails.application.config.after_initialize do
old_behaviour = ActiveSupport::Deprecation.behavior
ActiveSupport::Deprecation.behavior = ->(message, callstack) {
unless message.starts_with?('DEPRECATION WARNING: Extra .css in SCSS file is unnecessary.',
'DEPRECATION WARNING: Extra .css in SASS file is unnecessary.')
old_behaviour.each { |behavior| behavior[message,callstack] }
end
}
end
或者你可以修补补丁,不要生成这样的信息:
module DisableCssDeprecation
def deprecate_extra_css_extension(engine)
if engine && filename = engine.options[:filename]
if filename.end_with?('.css.scss','.css.sass')
engine
else
super
end
end
end
end
module Sass ; module Rails ; class SassImporter
prepend DisableCssDeprecation
end ; end ; end
答案 2 :(得分:1)
这个命令帮我重命名了很多.css.sass文件:
find ./app/assets/stylesheets -type f | sed 'p;s/\.css\.scss/.scss/' | xargs -n2 git mv