Symfony CMF CSS未加载:资源解释为样式表,但使用MIME类型text/html:传输



使用本教程,我正在尝试启动并运行Symfony2 CMF。我能够启动框架,但没有加载任何样式或脚本。我收到 js 和 css 的错误:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/3428277_bootstrap.min_1.css". en:14
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_font-awesome_3.css". en:32
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/3428277_style_3.css". en:28
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_create-ui_2.css". en:31
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_tags_1.css". en:30
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/3428277_bootstrap-responsive.min_2.css". en:21
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_overlay_7.css". en:36
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_createStyle_6.css". en:35
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_midgardnotif_4.css". en:33
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_jquery_1.js". en:283
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_jquery-ui_2.js". en:284
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://cmf.local/app_dev.php/css/06935bc_halloCmfStyle_5.css". en:34
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_underscore_3.js". en:285
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_rangy-core_5.js". en:287
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_vie_6.js". en:288
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_backbone_4.js". en:286
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_jquery.rdfquery.core_7.js". en:289
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_jquery.rdfquery.rules_8.js". en:290
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_annotate_10.js". en:292
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_create_11.js". en:293
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/create_jquery.tagsinput_9.js". en:291
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/ckeditor_ckeditor_1.js". en:297
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/ckeditor_init-create-ckeditor_2.js". en:298
Resource interpreted as Script but transferred with MIME type text/html: "http://cmf.local/app_dev.php/js/ckeditor_init-create-common_3.js". 

这些样式和脚本是从 skeleton.html.twig 加载的:

{% stylesheets
    ...             
    <link rel="stylesheet" href="{{ asset_url }}" media="screen" type="text/css"/>
 {% endstylesheets %}

{% block bottom_scripts %}
            {% render(controller("cmf_create.jsloader.controller:includeJSFilesAction", { "editor": "ckeditor", "_locale": app.request.locale })) %}
{% endblock %}

从教程中,这些样式应该加载正常。我也在这里使用了 CMF 文档,并且可以加载样式,但文档遇到了许多其他问题。也许我需要在我的 config.yml 中调整一些东西吗?

更新

这似乎是资产的问题。如果我手动将样式加载到骨架.html.twig中,它们就会出现。

资产会导致这种哑剧类型转移的任何原因?在这个庞大的框架中,我有一些设置不正确?

尝试转储资产:

$  app/console assetic:dump

09:27:19 [file+] /var/www/app/../web/css/06935bc.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_tags_1.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_create-ui_2.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_font-awesome_3.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_midgardnotif_4.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_halloCmfStyle_5.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_createStyle_6.css
09:27:19 [file+] /var/www/app/../web/css/06935bc_overlay_7.css
09:27:19 [file+] /var/www/app/../web/js/ckeditor.js
09:27:19 [file+] /var/www/app/../web/js/ckeditor_ckeditor_1.js
09:27:19 [file+] /var/www/app/../web/js/ckeditor_init-create-ckeditor_2.js
09:27:19 [file+] /var/www/app/../web/js/ckeditor_init-create-common_3.js
09:27:19 [file+] /var/www/app/../web/js/create.js
09:27:19 [file+] /var/www/app/../web/js/create_jquery_1.js
09:27:19 [file+] /var/www/app/../web/js/create_jquery-ui_2.js
09:27:19 [file+] /var/www/app/../web/js/create_underscore_3.js
09:27:19 [file+] /var/www/app/../web/js/create_backbone_4.js
09:27:19 [file+] /var/www/app/../web/js/create_rangy-core_5.js
09:27:19 [file+] /var/www/app/../web/js/create_vie_6.js
09:27:19 [file+] /var/www/app/../web/js/create_jquery.rdfquery.core_7.js
09:27:19 [file+] /var/www/app/../web/js/create_jquery.rdfquery.rules_8.js
09:27:19 [file+] /var/www/app/../web/js/create_jquery.tagsinput_9.js
09:27:19 [file+] /var/www/app/../web/js/create_annotate_10.js
09:27:19 [file+] /var/www/app/../web/js/create_create_11.js
09:27:19 [file+] /var/www/app/../web/js/hallo-extra.js
09:27:19 [file+] /var/www/app/../web/js/hallo-extra_jquery.htmlClean_1.js
09:27:19 [file+] /var/www/app/../web/js/hallo-extra_hallo_2.js
09:27:19 [file+] /var/www/app/../web/js/hallo-extra_init-create-hallo_3.js
09:27:19 [file+] /var/www/app/../web/js/hallo-extra_init-create-common_4.js

这是一种解决方法,因为文档没有建议这种方法,但是在我遇到同样的问题之后,为我解决这个问题的是在输出属性中设置 css 文件的扩展名。默认情况下,它们最终在没有扩展名的情况下链接。

{% stylesheets '@asset_test_css' output="css/test.css" %}

相关内容

最新更新