Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt usemin failing to insert rev'd image paths into jade partials

I'm using a stock yeoman angular-fullstack generator - this problem occurs when executing grunt serve:dist. Images are successfully rev'd, but the updated image paths are not added to any of the jade views.

The usemin block:

usemin: {
  html: ['<%= yeoman.dist %>/views/**/*.html',
         '<%= yeoman.dist %>/views/**/*.jade'],
  css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
  options: {
    assetsDirs: ['<%= yeoman.dist %>/public']
  }
},

I've changed the html target to recursive globbing as I most of my jade files are within a "partials" directory. However, a fresh angular-fullstack project also has jade files in a partials directory and image replacement works as expected.

Folder structure - source files:

/app/views/*
/app/images/*
/app/scripts/*
/app/styles/

Folder structure - dist files:

/dist/views/*
/dist/public/images/*
/dist/public/scripts/
/dist/public/styles/

Revving works for CSS and JS files, just not images.

Example of an image path in jade partial:

img(src='/images/old_landing/record-landing.png')

Let me know if any other info is helpful.

like image 488
max Avatar asked Feb 15 '14 00:02

max


1 Answers

I had very similar problem - references to rev'd images failing to get updated in css. Always used to work when usemin had dirs: for options rather than assetsDirs: - so guess may be some change there undocumented. I don't know if this will work for you - but it did for me - in usemin options I changed

assetsDirs: ['<%= yeoman.dist %>']

to

assetsDirs: ['<%= yeoman.dist %>/**/']

or perhaps in your case, a more targetted might be (guessing!)

assetsDirs: ['<%= yeoman.dist %>/public/**/']

like image 65
Mike Avatar answered Oct 31 '22 14:10

Mike