mariusbalcytis / webpack-bundle

Bundle to Integrate Webpack into Symfony
MIT License
122 stars 36 forks source link

All bundles are parsed not only the listed ones #35

Closed mvrhov closed 7 years ago

mvrhov commented 7 years ago

I'm getting the following error when trying to dump in production mode.

Twig_Error_Syntax: Unknown "profiler_dump" function in "..../symfony/symfony/src/Symfony/BundleSecurityBundle/Resources/views/Collector/security.html.twig" at line 100

This indicates, that even though I have listed the bundles that are supposed to be parsed all bundles are still processed.

mariusbalcytis commented 7 years ago

By default, all errors are suppressed in dev environment and in others all "unknowns" are suppressed - this should be the case for your current error.

Furthermore, I've added separate test-case - it seems that bundle configuration is working fine.

Currently I'm unable to reproduce the issue.

What version of this bundle are you using? Have you configured twig.suppress_errors? What's the value of asset_providers?

mvrhov commented 7 years ago

This is not run in dev environment but in a production one. console maba:webpack:compile is run as a part of a "dist" build.

The version I'm running is 0.5.2. I haven't configured neither twig.suppress_errors nor asset_providers, so they have default values.

P.S. This is my config

maba_webpack:
    config:
        parameters:
            extract_css: true       # css should be in link tags and not loaded by js
    aliases:
        register_bundles:           # only load from next bundles
            - AppDefaultBundle
            - AccountBundle

So according to docs only twig files from those bundles are supposed to be parsed + the files in App/Resources. However the error message indicates that this is not the case.

mariusbalcytis commented 7 years ago

The issue is that aliases configuration key is only for aliases. If you want to exclude some resources where assets can be found, asset_providers is the configuration you want. So, in your case, you should use this configuration:

maba_webpack:
    config:
        parameters:
            extract_css: true       # css should be in link tags and not loaded by js
    asset_providers:
        -
            type:     twig_bundles
            resource:                         # here comes analysed bundles
                - AppDefaultBundle
                - AccountBundle
        -    # this is needed if you still need app folder - providing `asset_providers` overrides default values
            type:     twig_directory
            resource: %kernel.root_dir%/Resources/views

Could we make it clearer in the documentation?

Should aliases.register_bundles be removed, as it's usually just fine providing all aliases?

Of course, configuration could just include enabled bundles (for all use-cases, like asset providers and aliases) - this would be a lot clearer, but would probably need backwards incompatible changes or even more confusion.

P.S. Error is just a log with warning level - assets should be dumped correctly. Of course, it would be faster without analyzing all of them.

mariusbalcytis commented 7 years ago

Bundle configuration was refactored - now it includes single enabled_bundles node for both aliases and twig templates, this should make things clearer.