Search code examples
gruntjsassemble

How to omit a folder from the output file structure of a Grunt task


Im running a grunt task to build an Assemble site.

My task is configured as follows:

    assemble: {

        options: {
            flatten: false,
            assets: '<%= config.dist %>',
            dist: '<%= config.dist %>',
            layout: 'default.hbs',
            layoutdir: 'templates/layouts/',
            partials: 'templates/partials/*.hbs',
        },

        pages: {
            files: { '<%= config.dist %>': ['pages/{,*/}*.hbs'] }
        }

    },

In my source files, I have a structure like this:

 pages
    cat1
    cat2

This is outputting something like:

  dist
      pages
         cat1
         cat2

How can I setup the task so that it won't include the /pages folder but still generate the subfolders?


Solution

  • @jakerella is close but missing one piece, ext. It should be:

    files: [
      {
        expand: true, 
        cwd: 'pages', 
        src: ['**/*.hbs'], 
        dest: '<%= config.dist %>/', 
        ext: '.html'
      }
    ]