Webstorm 6 - 如何让 scss 文件观察器忽略文件 [英] Webstorm 6 - How to make the scss file watcher ignore files

查看:65
本文介绍了Webstorm 6 - 如何让 scss 文件观察器忽略文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望 SCSS 文件的文件观察器忽略文件名以下划线开头的文件,例如 _buttons.scss.

我该怎么做?

解决方案

首先在要忽略的文件中添加一个 _... 完成!来自文档:

<块引用>

部分

如果您有一个 SCSS 或 Sass 文件想要导入但不想要要编译成 CSS 文件,可以在开头添加下划线的文件名.这将告诉 Sass 不要将其编译为普通的 CSS文件.然后,您可以在不使用下划线的情况下导入这些文件.

例如,您可能有 _colors.scss.然后没有 _colors.css 文件将被创建,你可以做

@import "颜色";

所以添加下划线就可以了.只是不要导入.

小心命名你的文件,因为如果你有 style.scss_style.scss Sass 会将它们视为相同的文件名并抛出错误:

<预><代码>>>>检测到的更改为:/Users/allcaps/test/style.scss警告:在/Users/allcaps/test 中:有多个文件与名称style.scss"匹配:_style.scss样式文件

一个简单的解决方法是添加两个下划线:__style.scss.

I would like the file watcher for SCSS files to ignore files with file names starting with an underscore, for example _buttons.scss.

How would I do that?

解决方案

Start by adding a _ to a file that you want to be ignored... Done! From the documentation:

Partials

If you have a SCSS or Sass file that you want to import but don’t want to compile to a CSS file, you can add an underscore to the beginning of the filename. This will tell Sass not to compile it to a normal CSS file. You can then import these files without using the underscore.

For example, you might have _colors.scss. Then no _colors.css file would be created, and you can do

@import "colors";

So adding an underscore will do the job. Just don't import.

Be careful naming your files because if you have a style.scss and _style.scss Sass will see these as the same filename and trow an error:

>>> Change detected to: /Users/allcaps/test/style.scss
WARNING: In /Users/allcaps/test:
  There are multiple files that match the name "style.scss":
    _style.scss
    style.scss

A simple workaround will be to add two underscores: __style.scss.

这篇关于Webstorm 6 - 如何让 scss 文件观察器忽略文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆