Symfony 3.4 : Assetic 404 not found

507 Views Asked by At

I need to add another js script in a view.

So I created a new configuration in my assetic.yml file :

assetic:
    debug: "%kernel.debug%"
    use_controller: false
    bundles:
      - AppBundle

    filters:
        cssrewrite: ~
        uglifyjs2:
            bin: '%kernel.root_dir%/Resources/node_modules/uglify-js/bin/uglifyjs'
        uglifycss:
            bin: '%kernel.root_dir%/Resources/node_modules/uglifycss/uglifycss'
        less:
            node_paths: ['%kernel.root_dir%/Resources/node_modules/', '%kernel.root_dir%/Resources/node_modules/less/node_modules/']
            apply_to: '\.less$'

    assets:
        app_gestion_poste_js:
            inputs:
                - '@AppBundle/Resources/public/js/GestionPoste/gestion.js'
            filters: [?uglifyjs2]
            output: js/poste/gestion-poste.js

And I added my script in my twig file :

{% block foot_script_assetic %}
    {{ parent() }}
    {% javascripts
        '@app_another_script_js'
        '@app_gestion_poste_js'
    %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}
{% endblock %}

I ran these commands :

  • php bin/console assets:install
  • php bin/console assetic:dump

A lot of files are dumped in the web folder. I can find my file in web/js/poste/gestion-poste.js, and also in web/bunde/... But when I run my page, there are some 404 not found error :

> GET http://myapp/js/d6e0c99_part_1.js?00.02.00 404 (Not Found)
> GET http://myapp/js/d6e0c99_part_2.js?00.02.00 404 (Not Found)
> GET http://myapp/js/d6e0c99_part_1.js?00.02.00 404 (Not Found)
> GET http://myapp/js/d6e0c99_part_2.js?00.02.00 404 (Not Found)
  • Both files are not found.
  • Why the files are loaded twice ?

If I remove my new script from the assetic instruction, the first script works and is found :

{% block foot_script_assetic %}
    {{ parent() }}
    {% javascripts
        '@app_another_script_js'
    %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}
{% endblock %}

If I add the script into another view, I have the same issue. All the scripts of the page are not found.

I tried to :

  • change the rights of my JS file
  • change the js file content by a simple script like : console.log('hello');
  • copy/paste another js file which works and use it in the assetic.yml configuration

There is the same issue in the prod environment :(

Thanks !

0

There are 0 best solutions below