yeoman / bower-requirejs

[DEPRECATED] Automagically wire-up installed Bower components into your RequireJS config
375 stars 68 forks source link

Only add to an existing file #111

Open redolent opened 9 years ago

redolent commented 9 years ago

We have a hand-written require config with a lot of comments. Wanted to know if there is interest in working on a version that doesn't touch the file except minimally.

There's a project someone already started on: https://github.com/xerona/bower-requirejs

mwcz commented 9 years ago

I had the same problem. Here's the solution I came up with:

  1. Keep the hand-written require config, require.hand-config.js
  2. Create a new require config file just for bower deps. I called it require.bower-paths.js
  3. At build time, concatenate require.hand-config.js and require.bower-paths.js into require.config.js

This works because RequireJS allows require.config({ ... }) to be called multiple times. I've been using this approach for several months and haven't found any downsides yet.