An open API service indexing awesome lists of open source software.

https://github.com/olsonpm/root-loader


https://github.com/olsonpm/root-loader

Last synced: about 1 year ago
JSON representation

Awesome Lists containing this project

README

          

# root-loader

a two-line loader that expands root paths to the configured root directory

For example the following directory structure inside `/path/to/project`
```
webpack.config.js

lib/
utils.js

client/
js/
index.js
```

and the following loader configuration

```js
{
test: /\.js$/
, exclude: /(node_modules)/
, loader: 'root'
, query: {
rootPath: __dirname
}
}
```

would expand this require statement

```js
// client/js/index.js
require('/lib/utils');
```

into
```js
// client/js/index.js
require('/path/to/project/lib/utils');
```