GruntJS usemin doesn't look in subfolders
Asked Answered
L

1

6

I'm using grunt and usemin with my angularjs project. Specifically my issue is concerned with usemin not revving image tags in any *.html file within a subdirectory of views.

My .html files are in the following structure

dist/
    index.html
    views/
        profile.html
        partials/
            header.html
            ...

The grunt usemin:html task is processing everything in views/ but not within any of it's subfolders. ie. partials/*

Here is my grunt config:

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

What I've Tried

I tried adding these options to my usemin config:

options: {
    basedir: '<%= yeoman.dist %>',
    dirs: ['<%= yeoman.dist %>/**/*']
}

But still it doesn't process any subfolder of views.

Update

Thanks to jakerella's answer noa's comment I got the following to work:

usemin: {
  html: ['<%= yeoman.dist %>/{,*/}*.html', '<%= yeoman.dist %>/views/{,*/}*.html'],
  css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
  options: {
    dirs: ['<%= yeoman.dist %>']
  }
},
Litigation answered 31/12, 2013 at 15:25 Comment(0)
R
8

I think you're close, but I think you'll want to use the ** glob pattern in the html target of the usemin task:

usemin: {
    html: ['<%= yeoman.dist %>/**/*.html'],
    ...
}

And you might need an expand: true in there as well (but not sure if the usemin task uses that option).

Rendition answered 31/12, 2013 at 15:52 Comment(3)
Thanks just trying this now. Seems to be processing everything in the dist folder. ie. things within my components directory as well. Can this be changed to be anything within views?Litigation
Actually I'd need just index.html of dist and then everything within dist/viewsLitigation
Sure, just put multiple quoted patterns in that html array.Franky

© 2022 - 2024 — McMap. All rights reserved.