mariusbalcytis / webpack-bundle

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

TwigDirectoryAssetProvider Enhancement Ideas.. #83

Closed antonyoneill closed 1 year ago

antonyoneill commented 6 years ago

Hey @mariusbalcytis

One of my biggest vices with Assetic is that it looks at all of our thousands of twig files within our handful of bundles and has to parse them to generate the assets - it takes a long time to do and it's very sluggish.

I understand that this approach allows us to forget about defining the bundles/entry points in a config file and let them be found automatically at compile time making it easier to develop your applications.

I wonder if there are some improvements that can be made - off the top of my head I've come up with a few ideas, some terrible, some not..

I'd be happy to look into implementing any of these as a PR, but would like to get your thoughts on it first.

Thanks again for an awesome bundle!

Antony

mariusbalcytis commented 6 years ago

First of all, are you sure that parsing those twig files really takes that much time? In my experience, webpack compilation most often is the bottleneck. Of course your configuration is probably different - lots of twig files and not that many assets.

About manually providing the list of entry points - this approach is possible but I don't see much point in using the bundle in this case, as it's practically the main feature. If that's an option, you could consider defining your entry points in webpack configuration file itself. In that case, to get the resulting URL, you could use core symfony feature to get asset URLs from manifest file (it's documented somewhere in encore documentation, even if I don't see direct relationship between them).

Configuring a different pattern would be quite simple option - it could easily be made configurable if really needed. Of course, it requires manual work (and a good memory) to make it work. If you want to use webpack in any of twig files, you need to rename it and rename all usages alongside.

I'd also like to note that there's cache used (by twig file modification date), but it's meant for iterations when running dev-server command. What's your use-case, does it bother you on deployment or while developing?

antonyoneill commented 1 year ago

Apologies for not coming back on your points above. I've since moved on from that role and this issue no longer holds any relevant value.

Thanks again for the library.