Grunt usemin with templates

Posted by gang on Stack Overflow See other posts from Stack Overflow or by gang
Published on 2013-04-01T16:06:27Z Indexed on 2013/06/26 10:21 UTC
Read the original article Hit count: 340

Filed under:
|

Given the following directory structure:

– Gruntfile.js
– app
    |– index.php
    |– js
    |– css
    |– templates
         |– template.php
– dist

How can I configure grunt usemin to update the references to styles and scripts in my template file relative to the index.php which uses the template?

currently the tasks look like this:

useminPrepare: {
    html: '<%= yeoman.app %>/templates/template.php',
    options: {
        dest: '<%= yeoman.dist %>'
    }
},
usemin: {
    html: ['<%= yeoman.dist %>/{,*/}*.php'],
    css: ['<%= yeoman.dist %>/css/*.css'],
    options: {
        dirs: ['<%= yeoman.dist %>']
    }
}

And the blocks inside of the template look like this:

<!-- build:js js/main.js -->
    <script src="js/script1.js"></script>
    <script src="js/script2.js"></script>
<!-- endbuild -->

© Stack Overflow or respective owner

Related posts about gruntjs

Related posts about yeoman