Sign in
Log inSign up

How to manage views and files with hashes?

Rafael Rozon's photo
Rafael Rozon
·Mar 30, 2018

I'm responsible for a Laravel web app that serves multiple pages, each one being a React "SPA". When I deploy on production I run a build script that will:

  1. run Webpack, which outputs the files with a hash and creates a manifest file;
  2. run a Gulp task that will find all the views, search for html comments, and inject the updated file names;

Then I commit everything and deploy.

One of the things I would like to improve is regarding the views and the hashes. Currently I rely on some conventions to get the whole setup working. For example, the name of the Webpack entries have to be the name of the views. So, I can find the right file to inject the updated file names.

I would like a more declarative approach and I'm writing a library to solve this problem using a configuration file, updated by Webpack, to know what to inject and where.

So, my questions are:

  1. How do you manage to update views (html, templates, etc) with the correct path for hashed file names?
  2. What are the problems managing frontend assets (js, css, font files, etc) that you'd like to get solved?

Thank you!

EDIT I wrote an open-source project to address this problem and other problems about managing assets in frontend applications: Frontend Assets Manager

Any feedback is welcome!

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct