Search code examples
htmlgitminify

Git web development workflow, commit links to minified css and js?


I have read about implementing git hooks to minify css and js source files post-commit (as minified assets shouldn't be committed) but what is the best practice when committing the actual links to these within HTML pages?

The only options I can think of are:

Git commit HTML pages with links to minified source files, but without minified source files in the repository:

<link href="/assets/css/application.min.css" rel="stylesheet">
<script src="/assets/js/application.min.js"></script>

Git commit HTML pages with links to the development source files and change to minified once deployed:

<link href="/assets/css/application.css" rel="stylesheet">
<script src="/assets/js/application.js"></script>

I am sure there is a simple and effective workflow to achieve this that I am unaware of.


Solution

  • I have decided on the route of committing links to minified source files within HTML pages, but without minified source files in the repository. This means that I am relying on an intermediate tool (such as CodeKit) to automatically minify source files for me as I work on the development versions but it is a workflow that is working well for me so far.