loader-runner
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Loader-runner is a very useful package within the webpack suite of tools. It operates by running loaders, which are specialized functions designed to transform and preprocess files. This tool is particularly helpful for tasks involving bundling files, loading CSS or converting ES6 to ES5 javascript code, among others.
Using loader-runner involves importing the runLoaders
method from the "loader-runner" package into your Javascript file. Once imported, you will define various parameters such as the resource, loaders, context, processResource, and readResource within the runLoaders
configurational object.
Here is a code sample illustrating the correct usage:
import { runLoaders } from "loader-runner";
runLoaders({
resource: "/abs/path/to/file.txt?query",
loaders: ["/abs/path/to/loader.js?query"],
context: { minimize: true },
processResource: (loaderContext, resourcePath, callback) => { ... },
readResource: fs.readFile.bind(fs)
}, function(err, result) {
// handle errors and results here
})
This configures loader-runner to process file.txt
, using the loader.js loader. The context for this setup is specified as { minimize: true }
, and there are also specifications for processResource
and readResource
functions, governing how the resource is processed and read, respectively.
The primary documentation for loader-runner appears to be contained in the README file of the GitHub repository, which can be found at https://github.com/webpack/loader-runner. It's currently noted in the README that more documentation is coming soon, so it might be worth checking back periodically for more detailed and updated instructions.