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

StackOverflow https://stackoverflow.com/questions/18595609

  •  27-06-2022
  •  | 
  •  

Question

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?

Was it helpful?

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
}

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top