Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

brunch

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?

like image 588
Lt. Avatar asked Sep 03 '13 15:09

Lt.


2 Answers

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
}
like image 159
Lt. Avatar answered Nov 01 '22 23:11

Lt.


Just thought I'd comment on how my function looks like if someone have a hard time figuring out how to proceed:

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|assets)\/.*\.(html|png|jpg|jpeg|eot|svg|ttf|woff)/.test(path);
}

This will move files, in both the app- and assets-folder, with the extensions: html, png, jpg, jpeg, eot, svg, ttf, woff to the public-folder.

I've decided to move our assets-folder to the root-structure, so our structure looks like this now:

frontend
  - app
  -- common/
  -- styles/
  -- etc etc
  - assets
  -- index.html
  -- css/
  -- images/
  -- etc etc
like image 2
jwanglof Avatar answered Nov 01 '22 22:11

jwanglof