jmm / pathmodify

In a nutshell, rewrite (AKA alias, map) `require()` IDs / paths / directories to different values in browserify.
MIT License
27 stars 1 forks source link

command-line usage: .pathmodifyrc or ? #8

Open dey-dey opened 8 years ago

dey-dey commented 8 years ago

been looking for something like this that actually works for a while, so thank you!

i'm curious if you'd accept PRs for setting config from command line. something like:

browserify index.js -o build/bundle.js -p [ pathmodify --config ./.pathmodifyrc ]

that way you can configure it for tools that don't allow programmatic configuration.

dey-dey commented 8 years ago

or simply checking for rc file

jmm commented 8 years ago

Thanks @daedelus-j!

Doing something like this has crossed my mind. I don't use the CLI, so it hasn't been a high priority. Let me consider this.

Considering that you'd have to create a new file anyway, if you need this right now you can probably do something like:

var
  pathmodify = require("pathmodify");

module.exports = function (b, opts) {
  if (opts.cfgFile) {
    opts = require(opts.cfgFile);
  }
  return pathmodify(b, opts);
};
browserify index.js -o build/bundle.js -p [ ./pathmodify --cfg-file ./.pathmodifyrc ]

(Or just embed the cfg directly in that file if you prefer.)

dey-dey commented 8 years ago

good point :) this is easier. mind if i add this to the docs?

jmm commented 8 years ago

Thanks @daedelus-j! That sounds good, I just want to figure out where it should go. I want to keep the README focused. This is the second time something like this has come up, so I'm thinking of creating another page of docs about integrations and / or an examples directory.