Sublime Text 3 SASS 构建错误,无法构建 css 文件

whi*_*ian 4 css sass sublimetext3

我在 Sublime Text3 上使用 SASSBuild 将 style.scss 保存为嵌套的 .css,但一直失败,退出代码为 64。

所有安装都成功:-packages: SASS, SCSS, SASSBuild -SASS using brew -Preinstalled Ruby from Mac

当我尝试使用保存在桌面/SCSS 上的 style.scss 的 Tools->Build->SASS 时,它显示此消息并且没有任何反应:

Could not find an option named "cache".

Usage: sass <input.scss> [output.css]
       sass <input.scss>:<output.css> <input/>:<output/>

??? Input and Output ???????????????????
    --[no-]stdin               Read the stylesheet from stdin.
    --[no-]indented            Use the indented syntax for input from stdin.
-I, --load-path=<PATH>         A path to use when resolving imports.
                               May be passed multiple times.

-s, --style=<NAME>             Output style.
                               [expanded (default), compressed]

    --update                   Only compile out-of-date stylesheets.

??? Source Maps ????????????????????????
    --[no-]source-map          Whether to generate source maps.
                               (defaults to on)

    --source-map-urls          How to link from source maps to source files.
                               [relative (default), absolute]

    --[no-]embed-sources       Embed source file contents in source maps.
    --[no-]embed-source-map    Embed source map contents in CSS.

??? Other ??????????????????????????????
    --watch                    Watch stylesheets and recompile when they change.
    --[no-]poll                Manually check for changes rather than using a native watcher.
                               Only valid with --watch.

    --[no-]stop-on-error       Don't compile more files once an error is encountered.
-i, --interactive              Run an interactive SassScript shell.
-c, --[no-]color               Whether to emit terminal colors.
-q, --[no-]quiet               Don't print warnings.
    --[no-]trace               Print full Dart stack traces for exceptions.
-h, --help                     Print this usage information.
    --version                  Print the version of Dart Sass.
[Finished in 0.1s with exit code 64]
[cmd: ['sass', '--update', '/Users/adrian/Desktop/SCSS/style.scss:/Users/name/Desktop/SCSS/style.css', '--stop-on-error', '--no-cache']]
[dir: /Users/name/Desktop/SCSS]
[path: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
Run Code Online (Sandbox Code Playgroud)

我怎样才能让 SASSBuild 工作?提前致谢。

Jak*_*ris 5

当您安装了 Dart SASS(这是较新的首选模块)而不是 Node SASS 时,会发生此错误。内置脚本使用--no-cache了 Dart SASS 模块中不存在的选项。

您可以轻松添加自己的构建文件来代替内置文件:

在 Sublime 中,选择

Tools > Build System > New Build System...
Run Code Online (Sandbox Code Playgroud)

这将在您的 Sublime User文件夹中打开一个新文件。使用以下脚本:

{ 
    "cmd" : [
        "sass", 
        "--update", 
        ".:.", 
        "--stop-on-error", 
        "--style", 
        "compressed"
    ],
    "selector": "source.scss"
}
Run Code Online (Sandbox Code Playgroud)

你可以设置任何你想要的Dart SASS 选项,例如将压缩更改为扩展

有关 Sublime 构建系统的更多信息

然后,只需保存此文件(可能是Dart-SASS.sublime-build),然后从菜单中选择它作为您的构建系统。