Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: How do you update html file to use new minified & concatenated JS & CSS file?

I have a lot of CSS & JS files in my html, and i'm using YUI Compressor to minify & concat all of these into 1x CSS and 1x JS.

Is there a way for maven to go into my HTML file, remove the 20+ lines of & includes and replace with the one that is minified ?

like image 647
dalcu Avatar asked Dec 12 '25 13:12

dalcu


1 Answers

A good option is to use Grunt to replace the references within your html file. There is a Grunt plugin to do this: the grunt-usemin.

For example:

<!-- build:js js/app.minjs -->
<script src="js/controllers/thing-controller.js"></script>
<script src="js/models/thing-model.js"></script>
<script src="js/views/thing-view.js"></script>
<!-- endbuild -->

The output file:

<script src="js/app.min.js"></script>
like image 158
Luan Reffatti Avatar answered Dec 14 '25 02:12

Luan Reffatti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!