我正在用指南针/ sass尝试symfony2及其资产。但是当我只在dev环境中时,在编译的css文件中出错:
/*
[exception] 500 | Internal Server Error | Symfony\Component\Debug\Exception\ContextErrorException
[message] Warning: file_put_contents(): Filename cannot be empty in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php line 312
[1] Symfony\Component\Debug\Exception\ContextErrorException: Warning: file_put_contents(): Filename cannot be empty in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php line 312
at n/a
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php line 312
at Symfony\Component\Debug\ErrorHandler->handle('2', 'file_put_contents(): Filename cannot be empty', '/Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php', '312', array('asset' => object(FileAsset), 'root' => '/Users/kklaus/Workspace/Symfony/app/../web', 'path' => 'bundles/webdevblog/sass/style.scss', 'loadPaths' => array('/Users/kklaus/Workspace/Symfony/app/../web/bundles/webdevblog/sass'), 'tempDir' => '/private/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T', 'compassProcessArgs' => array('/usr/bin/ruby', '/usr/bin/compass', 'compile', '/private/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T'), 'pb' => object(ProcessBuilder), 'optionsConfig' => array('additional_import_paths' => array('/Users/kklaus/Workspace/Symfony/app/../web/bundles/webdevblog/sass'), 'sass_options' => array('cache_location' => '/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T'), 'http_path' => '/images'), 'config' => array('additional_import_paths = [
"/Users/kklaus/Workspace/Symfony/app/../web/bundles/webdevblog/sass"
]', 'sass_options = {
:cache_location => "/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T"
}', 'http_path = "/images"'), 'name' => 'http_path', 'value' => '/images', 'configFile' => false))
in line
at file_put_contents('', 'additional_import_paths = [
"/Users/kklaus/Workspace/Symfony/app/../web/bundles/webdevblog/sass"
]
sass_options = {
:cache_location => "/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T"
}
http_path = "/images"
')
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php line 312
at Assetic\Filter\CompassFilter->filterLoad(object(FileAsset))
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/FilterCollection.php line 62
at Assetic\Filter\FilterCollection->filterLoad(object(FileAsset))
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Asset/BaseAsset.php line 90
at Assetic\Asset\BaseAsset->doLoad('
body {
background-color: yellow;
}
h2 {
color: green;
}
p {
span {
font-weight: bold;
}
}', null)
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Asset/FileAsset.php line 65
at Assetic\Asset\FileAsset->load()
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Asset/BaseAsset.php line 99
at Assetic\Asset\BaseAsset->dump(null)
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCache.php line 69
at Assetic\Asset\AssetCache->dump()
in /Users/kklaus/Workspace/Symfony/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Controller/AsseticController.php line 88
at Symfony\Bundle\AsseticBundle\Controller\AsseticController->render('56ff856', '0')
in line
at call_user_func_array(array(object(AsseticController), 'render'), array('56ff856', '0'))
in /Users/kklaus/Workspace/Symfony/app/bootstrap.php.cache line 2844
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
in /Users/kklaus/Workspace/Symfony/app/bootstrap.php.cache line 2818
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
in /Users/kklaus/Workspace/Symfony/app/bootstrap.php.cache line 2947
at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
in /Users/kklaus/Workspace/Symfony/app/bootstrap.php.cache line 2249
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
in /Users/kklaus/Workspace/Symfony/web/app_dev.php line 28
*/
当我在prod环境中时,它可以工作。 CSS文件是正确的:
/* line 2, assetic_compass67JtN2.scss */
body {
background-color: yellow;
}
/* line 7, assetic_compass67JtN2.scss */
h2 {
color: green;
}
/* line 13, assetic_compass67JtN2.scss */
p span {
font-weight: bold;
}
config.yml中的Asstetic配置:
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
#java: /usr/bin/java
ruby: /usr/bin/ruby
filters:
cssrewrite: ~
sass:
bin: /usr/bin/sass
compass:
bin: /usr/bin/compass
有人知道错误在哪里以及为什么它对开发不起作用?
答案 0 :(得分:0)
感谢@Djuro Mandinic寻求解决方案:
转储dev环境的资产文件并查看它是否有帮助:directions here缺点是,如果您更改资产文件中的某些内容,则需要再次转储它。