如何在phpstorm中使用指南针? [英] How to use compass in phpstorm?

查看:69
本文介绍了如何在phpstorm中使用指南针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题: 如何向Jetbrains PhpStorm添加Compass语法支持?但没有帮助.

I'm aware of this question: How to add Compass syntax support to Jetbrains PhpStorm? but it doesn't help.

我只是选择将文件复制过来,所以在我的项目中要容易得多.但是phpstorm仍然抱怨指南针.如果没有指南针,它将使用ruby 1.9.3编译scss,而不会出现问题.我的设置正确吗?

I just opted for copying the files over, much easier in my project. But phpstorm still complains about compass. Without compass it compiles scss using ruby 1.9.3 without problems. Is my set up correct?

编辑:

这是针对PhpStorm 6的-

This is for PhpStorm 6-

在PhpStorm 7+中支持指南针

推荐答案

首先,您链接的问题是关于对Compass样式导入的支持,这是一种解决方法,不适用于每个项目.

First of all, the question that you had linked is about enabling support for Compass-style imports, and it is a workaround that does not work for every project.

您的问题是另一回事:编译Compass项目.

Your question is about a different thing: compiling Compass projects.

这两个问题都将在即将发布的PHPStorm的第7版中得到解决:第6版刚刚发布.目前,有许多解决方法.

Both issues will be addressed in the 7th version of PHPStorm, which is not going to be released soon: the 6th version has just been released. For now, there's a number of workarounds.

  1. 转到PHPStorm IDE设置的外部工具部分.
  2. 创建一个外部工具.将其命名为"Compass编译手册"或类似名称.
  3. 设置程序以指向您的Compass二进制文件.在Windows上就像C:\Ruby193\bin\compass.bat,在Linux和Mac上可以简单地是compass.但是,如果您使用的是RVM,则 Program 应该是bash.
  4. 对于所有操作系统,
  5. 参数字段应为compile,除非您使用的是RVM.对于RVM,应将参数设置为–login -c "compass compile".
  6. 工作目录字段应设置为$ProjectFileDir$.
  1. Go to the External tools section of PHPStorm IDE Settings.
  2. Create a new external tool. Name it "Compass compile manual" or similarly.
  3. Set the Program to point at your Compass binary. On Windows it's like C:\Ruby193\bin\compass.bat, on Linux and Mac it can be simply compass. But if you're using RVM, then the Program should be bash.
  4. The Parameters field should be compile for all OSes, unless you're using RVM. For RVM the Parameters should be set to –login -c "compass compile".
  5. The Working directory field should be set to $ProjectFileDir$.

可以从工具菜单启动手动编译.您还可以分配一个热键来更快地运行它.确保热键不会与现有的热键冲突.

Manual compilation can be launched from the Tools menu. You can also assign a hotkey to run it quicker. Make sure that hotkey does not collide with an existing one.

  1. 确保您具有最新的PHPStorm抢先体验预览版.您可以从此处下载.
  2. 确保已安装 File Watchers 插件.转到PHPStorm IDE设置的插件部分,查找 File Watchers .如果不在列表中,请通过安装 浏览存储库,然后重新启动PHPStorm.
  3. 如果尚未在PHPStorm中打开您的项目,请执行以下操作.
  4. 转到PHPStorm项目设置的文件监视程序部分.
  5. 创建一个文件查看器.使用自定义模板.将您的观察者命名为保存时进行Compass编译"或类似的名称.
  6. 根据您在项目中使用的文件类型,将文件类型设置为SCSS或SASS.
  7. 范围保留为项目文件"
  8. 设置程序以指向您的Compass二进制文件.在Windows上就像C:\Ruby193\bin\compass.bat,在Linux和Mac上可以简单地是compass.但是,如果您使用的是RVM,则 Program 应该是bash.
  9. 对于所有操作系统,除非使用RVM,否则
  10. Arguments 字段应为compile.对于RVM,参数应设置为–login -c "compass compile". UPD::@ ezekiel-victor建议为:–login -c "compile --sass-dir=$ProjectFileDir$ --css-dir=$ProjectFileDir$".
  11. 工作目录字段应设置为$ProjectFileDir$.
  12. 禁用Check for syntax errors.
  13. 将其余部分留空并保存.
  1. Make sure you have the very latest Early Access Preview version of PHPStorm. You can download it from here.
  2. Make sure you have the File Watchers plugin installed. Go to the Plugins section of PHPStorm IDE Settings, look for File Watchers. If it's not on the list, install it via Browse repositories and restart PHPStorm.
  3. Open your project in PHPStorm if you haven't done it already.
  4. Go to the File Watchers section of PHPStorm Project Settings.
  5. Create a new File Watcher. Use a custom template. Name your watcher "Compass compile on save" or similarly.
  6. Set the File type to either SCSS or SASS, depending which one you use in your project.
  7. Leave the Scope as "Project files"
  8. Set the Program to point at your Compass binary. On Windows it's like C:\Ruby193\bin\compass.bat, on Linux and Mac it can be simply compass. But if you're using RVM, then the Program should be bash.
  9. The Arguments field should be compile for all OSes, unless you're using RVM. For RVM the Arguments should be set to –login -c "compass compile". UPD: @ezekiel-victor suggests this to be: –login -c "compile --sass-dir=$ProjectFileDir$ --css-dir=$ProjectFileDir$".
  10. The Working directory field should be set to $ProjectFileDir$.
  11. Disable Check for syntax errors.
  12. Leave the rest blank and save.

现在,每当您保存对任何SCSS或SASS文件的更改时,PHPStorm都会告诉Compass编译项目.

Now whenever you save changes to any of your SCSS or SASS files, PHPStorm will tell Compass to compile the project.

UPD 如果您使用的是Bundler(项目中有Gemfile,并且您执行了bundle install来获取依赖项),则应使用bundle exec compass compile而不是compass compile.这意味着您必须使用bundle可执行文件(在Windows上为bundle.bat)而不是compass(compass.bat),并相应地调整Arguments字段.

UPD If you're using Bundler (there's Gemfile in your project and you do bundle install to fetch dependencies), you shoud use bundle exec compass compile instead of compass compile. This means that you have to use the bundle executable (bundle.bat on Windows) instead of compass (compass.bat) and adjust the Arguments field accordingly.

运行compass compile的问题在于,它的速度较慢,因为它每次执行时都会重新编译整个项目.

The problem with running compass compile is that it's slow as it recompiles the whole project every time it is executed.

相反,您可以使用操作系统控制台在项目文件夹中手动运行compass watch命令. Compass Watch将不断监视您的项目中的更改.注意到更改时,它将仅重新编译已修改的部分,这要快得多.

Instead, you can run a compass watch command manually in the project folder using your OS console. Compass Watch will constantly monitor your project for changes. When changes are noticed, it will recompile only the modified part, which is much faster.

Compass Watch足够聪明,不会监视项目中的每个文件.它仅监视由任何非部分文件或递归导入的部分导入的非部分文件(例如screen.scss)和部分(例如_layout.scss).

Compass Watch is smart enough not to monitor every file in your project. It only monitors non-partial files (e. g. screen.scss) and partials (e. g. _layout.scss) that are imported by any non-partial file or by imported partials recursively.

如果您通过网络文件系统处理项目(例如,使用虚拟机或开发服务器运行代码时),则编译和跟踪更改将变得太慢.因此,在使用远程/虚拟机时,最好的选择是在该计算机上运行compass watch,以便它在本地而不是通过网络文件系统跟踪更改.

If you work with your project over a network filesystem (e. g. when using a virtual machine or a development server to run your code), compilation and tracking changes become too slow. So the best option when using remote/virtual machine is to run compass watch on that machine so that it tracks changes locally and not via a network file system.

指南针会缓存自己的工作,以加快编译速度.有时,缓存与项目内容不一致.这样导致Compass报告各种奇怪的错误,并拒绝编译您的项目.

Compass caches it's own work to make compilation faster. Sometimes the cache becomes inconsistent with project contents. This results in Compass reporting all kinds of weird errors and refusing to compile your project.

一旦您觉得Compass报告的错误不正确,请执行compass clean并重新编译您的项目.清理将清除Compass缓存和已编译的文件,以便从头开始.

Once you feel that Compass reports an error that is not true, execute compass clean and recompile your project. Cleaning will purge Compass cache and complied files, so that it starts from scratch.

您可以在控制台中手动运行compass clean或将其添加为PHPStorm外部工具.

You can run compass clean manually in console or add it as a PHPStorm External Tool.

这篇关于如何在phpstorm中使用指南针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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