doutui2016 2015-11-30 11:25
浏览 79

PHP Storm:在Symfony 2中设置SCSS

I am new to a Symfony 2 project that contains an SCSS file in the Resources folder: myproject.scss

In the head of the HTML files, the css version of this file gets included:

@MyBundle/Resources/public/css/myproject.css

PHP Storm indicates "Missing asset". The HTML cannot be rendered, Symfony2 says that the asset is missing.

I have never worked with SCSS. How do I achieve that on file change of my scss file the css file gets created/updated and Symfony2 no longer indicates a missing asset for my css path in my HTML file?

What I have done so far in order to solve this problem:

  • I installed SASS and Compass via the Ruby gem manager.
  • In PHPStorm, I configured a file watcher "SCSS", referencing to C:\Ruby\bin\scss.bat
  • 写回答

1条回答 默认 最新

  • duanbiao4035 2015-11-30 14:02
    关注

    After installing SCSS compiler and setting the right path in File Watcher settings your css will be generated every time you change your .scss file. This .css file is located by default near original .scss and so to copy it into the web directory you need manually copy it every time or configure your file watcher to do it for you instead.

    Also you can configure scssphp assetic filter to do it instead of PhpStorm. It will generate new css file every time you run php app/console assetic:dump command or every time asset is loaded via assetic controller.

    To work with Assetic you need next code:

    {% stylesheets filter="scssphp" output="css/myproject.css"
            @MyBundle/Resources/myproject.scss
    %}
        <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}
    
    评论

报告相同问题?

悬赏问题

  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题