Webpack-encore: Is there a way to use assets versioning strategy outside of Symfony?

Created on 1 Oct 2018  路  4Comments  路  Source: symfony/webpack-encore

I'm using Encore in a non-Symfony project and we don't have the assets component, so we want to use assets versioning strategy with our files, everything works fine, encore generates the manifest.json file with the mapping information, but, how to use it? in Symfony all is done automatically, should we read that file and generate the proper HTML tags dynamically? thanks in advance.

question

All 4 comments

Hi @EliuTimana

I write very basic class to work with manifest.json file and use it in my non-Symfony projects.

https://gist.github.com/vkryukov76/06258160f68a74e3ec1da23401dd9bf7

Hope it helps you.

Hi @EliuTimana,

I would say that it depends on the kind of app you are trying to build.

If it's a single page application then you could use the HTML Webpack Plugin to build your index.html page. You can add it to your Encore config with Encore.addPlugin(...).

If you are working on a multi-pages project then yes, you would need to read the manifest.json file using something like the assets component (note that you can add it to any PHP project, not only Symfony ones).

Thanks for your time, I got it working now, I have created a small C# class that maps the paths in the manifest file.

Let's close for now as "fixed", because it's hard to provide a generic solution that works in any kind of app and programming language. Thanks!

Was this page helpful?
0 / 5 - 0 ratings