1

我正在从 Textmate 切换到 Sublime,并且无法让“自定义菜单操作”在 Sublime 中工作。菜单操作是一位同事编写的一行代码,它编译 LESS(css 预处理器)[文件名].less 并在保存时自动缩小和更新 2 个其他文件。更新的文件是:1. [文件名].css 和 2. [文件名].css.vtl。我们使用在 Velocity 上运行的 CMS,我们使用这种方式将 css 扔到页面上以减少 http 请求。这听起来可能很愚蠢,但我们有一个包含 800 多个站点等的巨大多租户实例。下面是代码:

#!/bin/sh
# This compiles the LESS and creates a CSS and CSS.VTL file

# lessc is added to the usr/local/bin dir, add it to the path
PATH=$PATH:/usr/local/bin

# get the filename without the extension
FILENAME=${TM_FILEPATH%.*}

# get the filetype of the current file (will handle multiple . in the filepath)
FILETYPE=${TM_FILEPATH##*.}

# only compile if this is a less document
if [ "$FILETYPE" == "less" ]; then
  lessc "$TM_FILEPATH" "$FILENAME".css
  lessc "$TM_FILEPATH" "$FILENAME".css.vtl --compress
  echo "Successfully created the following files:"
  echo "$FILENAME.css"
  echo "$FILENAME.css.vtl"
else
  echo "Not a less file: $TM_FILEPATH"
  echo "File type is $FILETYPE"
fi

我是后端代码的新手,我不确定如何将其转换为 Python 并在 Sublime 中更新我的 LESS 包。感谢您的帮助,如果我错过了一些 stackoverflow 协议,我们深表歉意。这是我的第一篇文章。

-吸收瘤

4

0 回答 0