10

I want to minify all HTML pages and maintain the page's name and path on the dist folder. I want to loop through all folders.

The code below works fine but ONLY for the parent folder (which is this case app/views).

grunt.initConfig({
    htmlmin: {
        dev: {
            files: [{
                expand: true,
                cwd: 'app/views/**',
                src: '{,*/}*.html',
                dest: 'dist/views'
            }]
        }
    }
});

As you can notice, I tried the magic star at the path app/views/** and had no luck.

This is my folder structure:

app/views/
├── page1.html
├── blocks
│   └── block.html
├── page2.html
└── page3.html

In my case, every template gets minified, except the ones under app/views/blocks folder.

Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105

1 Answers1

12
cwd: 'app/views',
src: '**/*.html',
przno
  • 3,476
  • 4
  • 31
  • 45
  • doesn't work. the same output. Still does not dig into folders inside `app/views/` – Muhammad Reda Apr 07 '14 at 08:26
  • Works fine for me. What are your version of Grunt and htmlmin? – przno Apr 07 '14 at 11:03
  • 1
    For future usage, include expand: true, in files[{}] – Billy Jan 07 '15 at 14:11
  • per @Billy's comment, here is an SO post explaining what `expand:true` does: http://stackoverflow.com/questions/16977884/what-does-the-expand-option-do-in-grunt-contrib-copy-the-examples-all-use-it – D.Tate Apr 01 '16 at 00:03