Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wikiwi/value-loader
Webpack loader that executes file in a child compiler and return exports
https://github.com/wikiwi/value-loader
webpack-loader
Last synced: about 2 months ago
JSON representation
Webpack loader that executes file in a child compiler and return exports
- Host: GitHub
- URL: https://github.com/wikiwi/value-loader
- Owner: wikiwi
- License: mit
- Created: 2017-02-04T15:14:43.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-17T08:05:22.000Z (over 5 years ago)
- Last Synced: 2024-09-15T19:22:12.580Z (4 months ago)
- Topics: webpack-loader
- Language: JavaScript
- Size: 6.84 KB
- Stars: 4
- Watchers: 2
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Value Loader for Webpack
Like [val-loader](https://github.com/webpack-contrib/val-loader) but runs
file in a child compiler.Works with babel and TypeScript.
## Install
```bash
npm install --save-dev value-loader
```## Usage
``` javascript
let a = require("value-loader!./file.js");
// => excute file.js while compiling and
// take the result as javascript code for including
```This loader is also useful if you want to provide data for another loader:
``` javascript
require("css-loader!value-loader!./generateCss.js");
```Or if you like to generate a json export similar to the tojson-loader, but with loaders executed:
``` javascript
require("raw-loader!value-loader!./resource.json.js");
```## Config
Instead of getting the whole `exports` object you can set `name` to the
named export you want to retrieve.``` javascript
require("css-loader!value-loader?name=default!./generateCss.js");
```## Acknowledgement
This work is heavily based on the work done by Nathan Tran for
[css-in-js-loader](https://github.com/nthtran/css-in-js-loader).## License
MIT