Skip to content

adnanh/detachkify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

detachkify

Browserify transform that lets you use absolute paths in your node require statements.

How to use

browserify

var browserify = require('browserify');
var detachkify = require('detachkify');

var detachkifyConfig = {
    relativeTo: __dirname + '/src',
    verbose: false
}

var b = browserify();
b.transform(detachkify, detachkifyConfig);

grunt-browserify

browserify: {
    app: {
        src: ['src/app.js'],
        dest: 'demo/js/app.bundle.js',
        options: {
            transform: [
                ['detachkify', { relativeTo: __dirname + '/src', verbose: false }]
            ]
        }
    }
}

Let's say you have following tree:

src/
 |- components/
 |      |- header/
 |      |    `- HeaderView.js
 |      `- login/
 |           `- LoginView.js
 |- stores/
 |     `- UserStore.js
 | 
 `- app.js
package.json

And in your HeaderView.js you are referencing UserStore.js

require('../../stores/UserStore');

You can now use absolute path relative to src/

require('/stores/UserStore');

Note: All absolute paths must start with a slash (/)

About

Remove the ugly dots...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published