Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mogelbrod/apply-loader
Apply loader for webpack
https://github.com/mogelbrod/apply-loader
loader webpack webpack2
Last synced: about 1 month ago
JSON representation
Apply loader for webpack
- Host: GitHub
- URL: https://github.com/mogelbrod/apply-loader
- Owner: mogelbrod
- License: mit
- Created: 2015-09-25T11:00:00.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-28T12:04:42.000Z (over 7 years ago)
- Last Synced: 2024-09-29T18:39:36.588Z (about 2 months ago)
- Topics: loader, webpack, webpack2
- Language: JavaScript
- Size: 4.88 KB
- Stars: 25
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# apply loader for webpack
## Usage
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
The `apply` loader can be used to execute an exported JavaScript function (optionally with arguments) and export the returned value.
It will attempt to call the `default` export if defined, falling back to the basic export (i.e. `module.exports`).
``` javascript
// Call with multiple arguments
// => sourceFn(1, 2)
require("apply?args[]=1&args[]=2!functionReturningLoader");// Call with an object/array
// => sourceFn({a: 1, b:2})
require("apply?{obj: {a: 1, b: 2}}!functionReturningLoader");// Call with an object/array declared in the webpack.config
// => sourceFn(require('webpack.config').customConfig)
require("apply?config=customConfig!functionReturningLoader");
```## Webpack 2 configuration
``` javascript
use: [{
loader: 'apply-loader',
options: {
// => sourceFn({a: 1}, true)
args: [ {a: 1}, true ]
// => sourceFn({a: 1})
obj: {a: 1}
// => sourceFn(require('webpack.config').customConfig)
config: 'customConfig'
}
}
```## License
MIT (http://www.opensource.org/licenses/mit-license.php)