These are chat archives for brunch/brunch

30th
Jun 2016
Colin Bate
@colinbate
Jun 30 2016 13:00
My inline-css-brunch plugin could be configured to do that.
Jackson Ray Hamilton
@jacksonrayhamilton
Jun 30 2016 17:57
I feel like I would be misusing your plugin for this purpose, @colinbate. But it does look like a good starting point.
Colin Bate
@colinbate
Jun 30 2016 18:00
Yea, it would be easy to create a plugin which could be configured to handle certain file extensions, but since Brunch is all about conventions, you often see separate plugins. The fact that you can more easily configure my css plugin to also handle HTML was probably a bit cheeky
Would you expect to configure this hypothetical plugin with a list of extensions to handle?
Jackson Ray Hamilton
@jacksonrayhamilton
Jun 30 2016 18:03
Yep, the plugins API doesn't seem very privy to the idea of a generalized "text plugin". I guess it would be a "template" type? And as for specifying extensions, the extension could be anything, even no extension. For such a plugin, a user-customizable "pattern" configuration would probably be better, so they could specify e.g. directories to compile (in my case, "icons/").
Colin Bate
@colinbate
Jun 30 2016 18:07
in that case, you can just use the pattern configuration on inline-css-brunch and it will do what you want.
plugins: {
  inlineCss: {
    pattern: /^icons\//
  }
}
If it makes you feel better, I can publish the plugin under a more generic name :)
Jackson Ray Hamilton
@jacksonrayhamilton
Jun 30 2016 18:26
Lol, that probably would make me feel better.
If you're serious, it might also be worth investigating if we need to use jsEscape: https://github.com/requirejs/text/blob/d04de4ffd7bf5ba6cb80cdca2d40d4f6f52a1b1f/text.js#L61
Not sure if Node's fs module handles that already.
Colin Bate
@colinbate
Jun 30 2016 18:30
Currently it is run through JSON.stringify which takes care of the escaping
it is possible that there are faster alternatives
If you want some of the other functionality like striping the xml declarations or plucking the body out of HTML, I would recommend a specific plugin for those things. Anything generic would be just escape and return.
Jackson Ray Hamilton
@jacksonrayhamilton
Jun 30 2016 18:35
Without any benchmarking my bets would be on JSON.stringify
Agreed on "other functionality".
Colin Bate
@colinbate
Jun 30 2016 19:30
Sorry, I had to run to a meeting just before I managed to publish this: https://www.npmjs.com/package/text-brunch
If you can try it out, see if it meets your needs, I can then publish the formal 1.0.0 version
Jackson Ray Hamilton
@jacksonrayhamilton
Jun 30 2016 21:11
Sure, I'm trying it out now. Thanks for making it!
Jackson Ray Hamilton
@jacksonrayhamilton
Jun 30 2016 21:26
Works for me. The only suggestion I have would be to make the extension property customizable, too.
I also found the "order after" example a little confusing. Does that imply that an extensionless require may have difficult-to-predict behavior without customizing the order?
Colin Bate
@colinbate
Jun 30 2016 23:10
Yea so as you know you can require a file by the full name with extension and that will work fine. However if you want to refer to the file without extension you can too. But if there multiple files with the same extension-less file name then it is the first one listed which can be referenced that way. By default files are listed alphabetically so .js would sort after .css for example.
Also the extension property is only used when pattern isn't provided (at the core Brunch level). You could change it I suppose, but not in conjunction with pattern. If you'd rather configure a set of folders and extensions separately then I could do that and build up some regexes but as it is you can do pretty much anything