如何解决symfony css rewrite的问题

当你的css里有src('image/path')之类的东西的时候,你只能用
    {% stylesheets 
   'bundles/addepiprospection/css/*.less'
   filter='lessphp,cssrewrite,?yui_css'
         output='css/prospection.css' %}
            
    {% endstylesheets %}     
这种办法来解决,而且即便这样,那种@import css 文件的命令还是会出错,而且,这需要你每次都assets:install,这太让人烦躁了。
有个哥们这么说:
This fix for cssrewrite is to not use cssrewrite. Nor should you add bundle paths to your css. Instead, use output as follows:
   {% stylesheets 
        output="bundles/zaysoarbiter/css/forms2.css"
        '@ZaysoArbiterBundle/Resources/scss/forms2.scss'
    %}
        
    {% endstylesheets %}
This works in development mode because the whole 'bundles/...' is still just a virtual name. For production mode, use the asset:install and the assetic:dump to copy everything to your web directory. Relative paths in css will now work fine without any rewriting.
我觉得这也是目前为止一个比较简单的办法,@import之类的问题也不会有,反正到时候都要assets:install,就让他们mix在一起吧,又有什么关系,唯一不好的就是别人如果知道这个可以看到你的原始javascript和css/less文件,而不是compress之后的,不过,那不是我的问题,又有多少人会去试呢。

评论

发表评论

热门博文