Skip to content

Instantly share code, notes, and snippets.

@rikschennink
Last active November 2, 2017 12:41
Show Gist options
  • Save rikschennink/e0e47d9ec7d42459427abec0fc15f84d to your computer and use it in GitHub Desktop.
Save rikschennink/e0e47d9ec7d42459427abec0fc15f84d to your computer and use it in GitHub Desktop.
Browserify, relative paths?
  • src
    • main.js
    • ui
      • foo.js
      • bar.js

This command generates modules where identifiers have been set to absolute module paths:

browserify ./src/**/*.js -o ./dist/bundle.js --full-paths

Resulting module id:

"/Users/rikschennink/.../src/ui/foo.js"

Is there a way to make those module paths relative? If I omit the --full-paths command I'm left with indexes as module identifiers so that's not working.

I want to bundle all modules but still be able to reference them with require by path like this.

var module = require('/ui/foo');

I'm aware I can alias the modules but that would require aliasing every single module manually which is not really a workable solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment