简体   繁体   English

Symfony 3 - Assetic dump 适用于开发但不适用于生产

[英]Symfony 3 - Assetic dump works on dev but doesn't work on prod

I'm new with symfony 3 and I'm trying to develop a web app application.我是 symfony 3 的新手,我正在尝试开发一个 Web 应用程序。 To combine my css and js files, I've installed assetic bundle and I'm using it on dev mode, It works fine and I haven't any problems.为了结合我的 css 和 js 文件,我安装了资产包并且我在开发模式下使用它,它工作正常,我没有任何问题。

Then when I try to test my web app on production mode, css and js are not complete and the website doesn't work fine.然后,当我尝试在生产模式下测试我的 Web 应用程序时,css 和 js 不完整并且网站无法正常工作。

I've tried these two commands but nothing has changed:我试过这两个命令,但没有任何改变:

  • php bin/console assetic:dump -env=prod
  • php bin/console cache:clear --no-warmup -e prod

The only way to make production work is to set $kernel = new AppKernel('prod', true);使生产工作的唯一方法是设置$kernel = new AppKernel('prod', true); on app.php file, but I don't think this is the best solution.在 app.php 文件上,但我认为这不是最好的解决方案。

Any ideas?有任何想法吗?

Here my code on base template:这是我在基本模板上的代码:

{% block stylesheets %}
        {% stylesheets
        'css/dist/bootstrap.css'
        'css/dist/bootstrap-grid.css'
        'css/dist/bootstrap-reboot.css'
        'css/dist/font-awesome.css'
        'css/dist/sidenav.css'
        'css/dist/head.css'
        'css/dist/main.css'
        filter='cssrewrite' output='css/compiled/app.css' %}
        <link rel="stylesheet" href="{{ asset_url }}">
        {% endstylesheets %}
    {% endblock %}

As you can see I get my css files from <root>/web/css/dist/* and I dump on <root>/web/css/compiled/app.css the file is created on dump, But not all css are there.如您所见,我从<root>/web/css/dist/*获取我的 css 文件,然后在<root>/web/css/compiled/app.css上转储该文件是在转储时创建的,但并非所有 css 都是那里。

Same procedure for js files. js 文件的过程相同。

您也需要安装您的资产:

php bin/console assets:install --env=prod

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM