HTMLmin - How to dynamically compress all files inside a certain folder
Asked Answered
L

1

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.

Luht answered 6/4, 2014 at 12:22 Comment(0)
G
12
cwd: 'app/views',
src: '**/*.html',
Garibald answered 6/4, 2014 at 15:12 Comment(4)
doesn't work. the same output. Still does not dig into folders inside app/views/Luht
Works fine for me. What are your version of Grunt and htmlmin?Garibald
For future usage, include expand: true, in files[{}]Anni
per @Billy's comment, here is an SO post explaining what expand:true does: #16978384Caton

© 2022 - 2024 — McMap. All rights reserved.