如何在Linux / macOS上将Sass 1.14与NetBeans 8.2一起使用

时间:2018-10-11 10:16:03

标签: linux ubuntu netbeans sass

我曾经能够按照How to use SASS with Netbeans 8.0.1的顶部答案中的说明,在NetBeans 8上安装和使用Sass。

现在,对于当前版本的Sass(1.14.1),安装有所不同。基本上只是下载并解压缩。这样就完成了,我已经将NetBeans指向了正确的位置。但是,当前版本的Sass无法从NetBeans中正确运行:

"/opt/dart-sass/sass" "--cache-location" 
"/home/jasper/.cache/netbeans/8.2/sass-compiler"
"path_to_my.scss" "path_to_my.css"
Could not find an option named "cache-location".

使用Windows的Sass output error in Netbeans 8.2也涵盖了此错误。

我试图将缓存位置参数(类似于Windows的解决方案)添加到sass文件的这一行:

exec "$path/src/dart" --no-preview-dart-2 "-Dversion=1.14.1" "$path/src/sass.dart.snapshot" "$@"

但我无法使其正常运行(相同的错误不断出现)。

关于在Linux(Ubuntu)上如何从NetBeans 8.2中获取Sass 1.14.1的任何想法?

2 个答案:

答案 0 :(得分:1)

问题是--cache-location不再受支持,应将其删除。 "$@"使用所有原始参数。要删除前两个参数,您应该可以使用"${@:3}"(请参阅Process all arguments except the first one (in a bash script)),但是对于我来说,这导致了“替换错误”错误。因此,我选择使用shift 2删除它们:

#!/bin/sh
# Copyright 2016 Google Inc. Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.

# This script drives the standalone Sass package, which bundles together a Dart
# executable and a snapshot of Sass. It can be created with `pub run grinder
# package`.

follow_links() {
  file="$1"
  while [ -h "$file" ]; do
    # On Mac OS, readlink -f doesn't work.
    file="$(readlink "$file")"
  done
  echo "$file"
}

# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
path=`dirname "$(follow_links "$0")"`
shift 2
exec "$path/src/dart" --no-preview-dart-2 "-Dversion=1.14.1" "$path/src/sass.dart.snapshot" "${@}"

确保保留原始文件并创建一个仅用于NetBeans的副本,然后在其中进行更改。

macOS(家庭自制)

如果要查找Dart Sass的安装位置(使用Home Brew安装后),则位于此处:

/usr/local/Cellar/sass/{version}/bin

NetBeans 11

在NetBeans 11上,我不得不使用shift 3而不是shift 2

答案 1 :(得分:0)

我的回复很大程度上取决于Jasper de Vries'one:

似乎Netbeans只是添加了一些其他参数,而sass编译器不再支持这些参数。

对于我来说,Netbeans发出的完整命令是:

“” / home / alex / tools / dart-sass / sass“”-缓存位置“” /home/alex/snap/netbeans/common/cache/12.0/sass-compiler“”-调试信息“” /home/alex/projects/alexgheorghiu.com/web/aaa.scss“”“ /home/alex/projects/alexgheorghiu.com/web/aaa.css”

所以前三个参数

“-缓存位置”“ /home/alex/snap/netbeans/common/cache/12.0/sass-compiler”“ --debug-info”

必须“删除”或忽略。

因此,您需要更改 sass 文件或对其进行复制(最安全的方法) 并添加

shift 3

说明。

因此,如果您从原始版本开始,例如:

#!/bin/sh

# This script drives the standalone dart-sass package, which bundles together a
# Dart executable and a snapshot of dart-sass.

follow_links() {
  file="$1"
  while [ -h "$file" ]; do
    # On Mac OS, readlink -f doesn't work.
    file="$(readlink "$file")"
  done
  echo "$file"
}

# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
path=`dirname "$(follow_links "$0")"`
exec "$path/src/dart" "$path/src/sass.snapshot" "$@"

您需要以类似以下内容结束

#!/bin/sh

# This script drives the standalone dart-sass package, which bundles together a
# Dart executable and a snapshot of dart-sass.

follow_links() {
  file="$1"
  while [ -h "$file" ]; do
    # On Mac OS, readlink -f doesn't work.
    file="$(readlink "$file")"
  done
  echo "$file"
}

# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
path=`dirname "$(follow_links "$0")"`
shift 3
exec "$path/src/dart" "$path/src/sass.snapshot" "$@"

一个有趣的方面是Netbeans开发人员已知此错误(请参阅:Could not find an option named "cache-location"),但我无法实现这一点,因为在我的Xubuntu 18之下,Netbeans是“快照”,因此是netbeans.conf。文件是只读的。 但是,如果您可以修改该文件,则它可能是一种更干净的解决方案。