global-modulize
v0.0.1
Published
Make it easy to import any file by using config file.
Downloads
5
Readme
global-modulize
Introduction
Import a file by path is painful. Change the structure of folder likes a tragedy. So make it accessible globally.
// before
const lib = require('../../../folder/file');
// after
const gm = require('gm');
const lib = gm('lib-name');
When you move the file to another place, what you need is set the config file. Not all the files import the file.
Usage
Create a config file named .gm.js
to config name and which file the name is pointing.
export default {
root: '/',
entries: {
name1: './path/to/the/file1',
name2: './path/to/the/file2',
},
};
Then, when you want to import a file, use it like this:
const gm = require('global-modulize');
const lib1 = gm('name1');
const lib2 = gm('name2');