Val Loader
Provides data to another loader
Install
npm i val-loader --save
Usage
var a = require("val-loader!./file.js");
Don't forget to polyfill require
if you want to use it in node.
See webpack
documentation.
The excution of file.js has polyfill already applied.
Provide data for another loader:
require("css-loader!val-loader!./generateCss.js");
Maintainers
1.0.0 (2017-03-16)
Features
- change expected module API (caf2aab)
BREAKING CHANGES
- this commit introduces a major refactoring of the loader.
- remove node 0.10 and node 0.12 support
- the loaded module must now export a function
- this function will be called with the loader options
- this function must return an object with this structure
Property | Type | Description
:--------|:-----|:-----------
code
| string|Buffer
| Required. The code that is passed to the next loader or to webpack.
sourceMap
| SourceMap
| Optional. Will be pased to the next loader or to webpack.
ast
| any
| Optional. An Abstract Syntax Tree that will be passed to the next loader. Useful to speed up the build time if the next loader uses the same AST.
dependencies
| Array<string>
| Default: []
. An array of absolute, native paths to file dependencies that need to be watched for changes.
cacheable
| boolean
| Default: false
. Flag whether the code can be re-used in watch mode if none of the dependencies
have changed.
- the function may also return a promise for async results
- switch tooling to webpack-defaults