我可以配置 SASS 以使 scss 文件不在 Web 根目录中吗?

发布于 2024-10-22 02:00:35 字数 113 浏览 1 评论 0原文

看起来 SASS 默认会暴露 scss 文件,我觉得这很令人讨厌。有没有办法配置 SASS 在不在 Web 根目录中的文件夹中查找 scss 文件,但将它们编译到 public/stylesheets 文件夹中?

It looks like SASS by default exposes scss files which I find rather obnoxious. Is there a way to configure SASS to look for scss files in a folder that's not in the web root but compile them into the public/stylesheets folder?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鹿! 2024-10-29 02:00:35

是的!

如果您使用 Compass,那么您将拥有一个如下所示的文件 /config/compass.rb。在这里,我的 sass 文件位于 app/stylesheets 中,并保存在 tmp/stylesheets 中编译(以帮助 heroku 部署)

/config/compass.rb

# This configuration file works with both the Compass command line tool and within Rails.
# Require any additional compass plugins here.
project_type = :rails
project_path = Compass::AppIntegration::Rails.root
#project_path = RAILS_ROOT if defined?(RAILS_ROOT)
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "tmp/stylesheets"
sass_dir = "app/stylesheets"
environment = Compass::AppIntegration::Rails.env
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true

Yes!

If you use Compass, then you'll have a file /config/compass.rb that'll look like the following. Here I have my sass files in app/stylesheets and saving compiled in tmp/stylesheets (to help with heroku deployments)

/config/compass.rb

# This configuration file works with both the Compass command line tool and within Rails.
# Require any additional compass plugins here.
project_type = :rails
project_path = Compass::AppIntegration::Rails.root
#project_path = RAILS_ROOT if defined?(RAILS_ROOT)
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "tmp/stylesheets"
sass_dir = "app/stylesheets"
environment = Compass::AppIntegration::Rails.env
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
平生欢 2024-10-29 02:00:35

老问题,但实际上很简单,您只需将目录传递给 sass 而不是像这样的特定 .scss ;

sass --watch /location/to/you/scss/:/location/to/your/css

然后对 scss 的任何更改都将保存到您的 css 目录中,并且它也将遵循与您的 scss 目录相同的结构。

Old question but it's actually simple to do, you just pass the directories through to sass instead of specific .scss like so;

sass --watch /location/to/you/scss/:/location/to/your/css

Then any changes to scss will be saved into your css directory and it will also follow the same structure of your scss directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文