LESSC 将包含的文件编译成 CSS

LESSC Compiling Included Files Into CSS

我有以下文件结构:

--public_html/
  - css/
  - less/
    - _mixins.less
    - _variables.less
    - _theme.less
    - main.less

我正在使用带有文件观察器的 PhpStorm 运行 来自 NPM 的 LESSC。

我的文件观察器如下:

Program: /usr/local/bin/lessc
Arguments: --no-color $FileName$
Output paths to refresh: ../$FileNameWithoutExtention$.css

文件:

main.less:

@import "_variables.less";
@import "_mixins.less";
@import "_theme.less";

_theme.less 包含我的样式表,_variables.less_mixins.less 都是不言自明的。

当我修改并保存 main.less 文件 main.css 是在 css 文件夹中创建的。

但是,当我编辑 _theme.less 文件时,LESSC 也会创建一个 _theme.css 文件。

如何停止创建这些额外的文件?

如果您需要更多信息,请询问。

请确保 Track only root files 选项在特定的文件观察器设置中启用——它就是这样做的。

来自https://www.jetbrains.com/help/phpstorm/2016.3/new-watcher-dialog.html#d199014e291

When the File Watcher is invoked on a file, PhpStorm detects all the files in which this file is included. For each of these files, in its turn, PhpStorm again detects the files into which it is included. This operation is repeated recursively until PhpStorm reaches the files that are not included anywhere within the specified scope. These files are referred to as root files (do not confuse with content roots).

  • When this check box is selected, the File Watcher runs only against the root files.
  • When the check box is cleared, the File Watcher runs against the file from which it is invoked and against all the files in which this file is included recursively within the specified scope.