2

我在我们的生产服务器上启动和运行 Assetic 缓存破坏器时遇到了问题。Symfony2 (2.4) 配置为仅在生产时使用缓存破坏器。在我们的开发机器上,一切都像魅力一样。然而,在生产服务器上,Assetic 在转储资产时会生成如下文件名:

/web/js/starapple.min-c875bb6-7df71b9.js

并嵌入一个如下所示的链接:

http://starapple.nl/js/starapple.min-c875bb6.js

这会使我们生产服务器上的所有 css 和 js 资产链接失效。有没有人在生产中遇到过这个问题,如果有,你的解决方案是什么?

更新

config.yml 中的资产配置:

assetic:
    debug: "%kernel.debug%"
    use_controller: false
    bundles:
        - FrameworkBundle
        - SecurityBundle
        - TwigBundle
        - MonologBundle
        - SwiftmailerBundle
        - DoctrineBundle
        - AsseticBundle
        - StarAppleCRMBundle
        - StarAppleCalendarBundle
        - StarAppleChatBundle
        - StarAppleWebBundle
    filters:
        sass: ~
        compass:
            plugins: ['zen-grids']
        less:
            node: /usr/local/bin/node
            node_paths: [/usr/local/lib/node_modules]
            apply_to: "\.less$"
        cssrewrite: ~
        uglifyjs2:
            bin: /usr/local/bin/uglifyjs
        uglifycss:
            bin: /usr/local/bin/uglifycss
    assets:
        bootstrap_css:
            inputs:
                - %kernel.root_dir%/../vendor/twbs/bootstrap/less/bootstrap.less
                - %kernel.root_dir%/../vendor/twbs/bootstrap/less/responsive.less
            filters:
                - less
                - cssrewrite
            output: css/bootstrap.css
        bootstrap_js:
            inputs:
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-transition.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-alert.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-button.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-carousel.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-collapse.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-dropdown.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-modal.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-tooltip.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-popover.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-scrollspy.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-tab.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-typeahead.js
                - %kernel.root_dir%/../vendor/twbs/bootstrap/js/bootstrap-affix.js
            output: js/bootstrap.js

并在 config_prod.yml 中启用缓存破坏器:

assetic:
    workers:
        cache_busting: ~
4

0 回答 0