Search code examples
javascriptgruntjsassemble

Dropping a directory from 'src' to 'dest' paths in Grunt.js and Assemble


I'm trying to take source files from pages/*.hbs and get them into the root of the build directory. Currently, they're ending up in build/pages/*.html.

Here's my task config. I tried looking into Grunt's task configuration options but wasn't getting any luck.

    assemble: {
        options: {
            layout: 'layouts/default.hbs'
        },
        pages: {
            src: ['pages/*.hbs'],
            dest: 'build/'
        }

Solution

  • You need expand: true which enables extra options, along with cwd which allows you to specify but not include part of your src path.

    assemble: {
        options: {
            layout: 'layouts/default.hbs'
        },
        pages: {
            expand: true,
            cwd: 'pages'
            src: ['*.hbs'],
            dest: 'build/'
        }
    

    Building the Files object dynamically