brunch

Brunch config file conventions.assets: How to copy from non-default locations?


According to the brunch documentation the property "conventions.assets" in the config file should be a regexp, but I'm trying to include the following:

conventions: {
    assets: /^app\/.*\.html/
}

in order to add all the htmls into the public folder. (I know I can create an assets folder and include all the things there, but it's not possible by the moment according the structure we've agreed).

I think this property expect a directory, in this case could I fix this value in order to reach my goal?, with a function maybe?


Solution

  • Finally I could do that overriding the method what the property "assets" accepts.

    assets: function(path) {
        /**
         * Loops every path and returns path|true|false according what we need
         * @param   path    file or directory's path
         * @returns path    if it is a directory
         *          true    if it fit with the regular expression
         *          false   otherwise
         *
         */
        if( /\/$/.test(path) ) return path;
        return /^app\/.*\.html/.test(path); // RegExp for anything we need
    }