Modifying css / js links with Grunt after concatenating and minifying

0

I'm using Grunt in my project, I can concatenate them and minify them as desired. However I need to change the links on my page to the minified files. For example:

From:

<head>
    <script src="js/arquivo1.js"></script>
    <script src="js/arquivo2.js"></script>
    <script src="js/arquivo3.js"></script>
</head>

To:

<head>
    <script src="js/arquivo.min.js"></script>
</head>

I would like to know if there is a plugin for this (should have) and how to configure it.

EDIT

Only one page (index.html) contains the links. The other pages are linked using AngularJS. I'm also using Node.js to assist with Grunt.

    
asked by anonymous 18.05.2016 / 21:47

1 answer

1

There are a few. I particularly use this: link

I like this plugin because it allows you to not only rename files, like rebuild blocks or remove, according to your need and even if that code is not connected with some other grunt process.

For example:

<!-- build:remove -->
    <script type="text/javascript">
        //Algum código de teste
    </script>
<!-- /build -->

After doing the process, that code will be removed from the file.

There are several options you can see in the documentation.

Important!

Note that this process will not be linked to another one (at least I do not know a method to do this), that is, after concatenating and minifying the JS file, it will not html auto. Just like it's done for JS, it should be done for HTML.

Note: Note that for this technique it is recommended that you move ALL files to a new directory unique to production so it will not interfere with your code development.

    
18.05.2016 / 22:24