mariusbalcytis / webpack-bundle

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

Bundle provider directory override #61

Closed vini-btc closed 7 years ago

vini-btc commented 7 years ago

Hi,

Thanks for the great work done here so far. It will be amazingly useful in a project I'm currently working on.

I would like to know if there is any way to override https://github.com/mariusbalcytis/webpack-bundle/blob/6dce0c055ef4857a5c67e8fb48604edf86cca44f/src/Resources/config/services/providers.xml#L24 . In my project structure we have the templates next to their controllers, so it would be awesome if I could add them from there also.

Thank you once again!

mariusbalcytis commented 7 years ago

You could just register another asset provider using tag like this:

<service id="my_custom_asset_provider"
                 parent="maba_webpack.asset_provider.twig_directory.base"
                 public="false">
    <tag name="maba_webpack.asset_provider"/>
    <argument type="service">
        <service class="Maba\Bundle\WebpackBundle\AssetProvider\DirectoryProvider\BundlesDirectoryProvider">
            <argument type="service" id="kernel"/>
            <argument>/Controller</argument>
            <argument>%maba_webpack.enabled_bundles%</argument>
        </service>
    </argument>
</service>

Replace /Controller with directory relative to each bundle.

vini-btc commented 7 years ago

Thank you very much for the fast response! Will try it out later today.