1

我使用 scss 的 @import 语句将一些 scss 文件导入到一个较大的文件中。尝试转储资产时,出现以下异常:

$ php app/console assetic:dump --force --verbose
Dumping all dev assets.
Debug mode is on.
[file+] sf_project/app/../web/js/f389f05.js
        sf_project/src/Theaterjobs/MainBundle/Resources/public/js/jquery-1.6.3.min.js
[file+] sf_project/app/../web/js/f389f05_jquery-1.6.3.min_1.js
        sf_project/src/Theaterjobs/MainBundle/Resources/public/js/jquery-1.6.3.min.js
[file+] sf_project/app/../web/css/e9b81fe.css
        sf_project/src/Theaterjobs/MainBundle/Resources/assets/css/_base.scss
        sf_project/src/Theaterjobs/MainBundle/Resources/assets/css/_structure.scss
        sf_project/src/Theaterjobs/MainBundle/Resources/assets/css/theaterjobs.scss

  [RuntimeException]  

Exception trace:
 () at sf_project/vendor/assetic/src/Assetic/Filter/CompassFilter.php:278
 Assetic\Filter\CompassFilter->filterLoad() at sf_project/vendor/assetic/src/Assetic/Filter/FilterCollection.php:62
 Assetic\Filter\FilterCollection->filterLoad() at sf_project/vendor/assetic/src/Assetic/Asset/BaseAsset.php:83
 Assetic\Asset\BaseAsset->doLoad() at sf_project/vendor/assetic/src/Assetic/Asset/FileAsset.php:57
 Assetic\Asset\FileAsset->load() at sf_project/vendor/assetic/src/Assetic/Asset/BaseAsset.php:92
 Assetic\Asset\BaseAsset->dump() at sf_project/vendor/assetic/src/Assetic/Asset/AssetCollection.php:97
 Assetic\Asset\AssetCollection->dump() at sf_project/vendor/bundles/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:206
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->doDump() at sf_project/vendor/bundles/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:163
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->dumpAsset() at sf_project/vendor/bundles/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:62
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->execute() at sf_project/vendor/symfony/src/Symfony/Component/Console/Command/Command.php:214
 Symfony\Component\Console\Command\Command->run() at sf_project/vendor/symfony/src/Symfony/Component/Console/Application.php:194
 Symfony\Component\Console\Application->doRun() at sf_project/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:75
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at sf_project/vendor/symfony/src/Symfony/Component/Console/Application.php:118
 Symfony\Component\Console\Application->run() at sf_project/app/console:16

为提高可读性而缩短了路径:)

我们的 config.yml 看起来像这样

# Assetic Configuration
assetic:
    debug:          %kernel.debug%
    use_controller: false
    filters:
        cssrewrite: ~
        sass:
          bin: /usr/local/bin/sass
        compass:
          bin: /usr/local/bin/compass
        yui_js:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.6.jar"

我包括使用的样式表

{% stylesheets filter="compass,cssrewrite" '@TheaterjobsMainBundle/Resources/assets/css/*' %}
    <link rel="stylesheet" href="{{ asset_url }}" type="text/css" media="screen" charset="utf-8" />
{% endstylesheets %}

我不知道是怎么回事。我将向您转储任何可能有助于解决此问题的输出。

谢谢!

4

2 回答 2

1

事实证明,我正在包含样式表'@TheaterjobsMainBundle/Resources/assets/css/*'(在路径中带有通配符),而不是直接链接到使用 @import 导入所有 scss 部分的主 scss 文件。

所以 sf 也试图编译部分文件,但由于未设置的变量而失败。

不清除缓存也没那么有用:)

于 2011-11-10T21:10:35.517 回答
0

我认为当 Compass 进程无法执行或未正确完成时会引发异常。你确定你的指南针路径是正确的吗?我认为这是您在那里的默认设置,但根据您的系统,它可能会有所不同。例如在 Ubuntu Server 11.04 我的 SCSS 路径是:

sass: /var/lib/gems/1.8/bin/sass

因此,请确保指南针实际驻留在/usr/local/bin/compass而不是其他地方。

于 2011-11-07T13:54:07.037 回答