source: frontend/node_modules/loader-runner/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.8 KB
Line 
1# loader-runner
2
3```js
4import { runLoaders } from "loader-runner";
5
6runLoaders(
7 {
8 resource: "/abs/path/to/file.txt?query",
9 // String: Absolute path to the resource (optionally including query string)
10
11 loaders: ["/abs/path/to/loader.js?query"],
12 // String[]: Absolute paths to the loaders (optionally including query string)
13 // {loader, options}[]: Absolute paths to the loaders with options object
14
15 context: { minimize: true },
16 // Additional loader context which is used as base context
17
18 processResource: (loaderContext, resourcePath, callback) => {
19 // ...
20 },
21 // Optional: A function to process the resource
22 // Must have signature function(context, path, function(err, buffer))
23 // By default readResource is used and the resource is added a fileDependency
24
25 readResource: fs.readFile.bind(fs),
26 // Optional: A function to read the resource
27 // Only used when 'processResource' is not provided
28 // Must have signature function(path, function(err, buffer))
29 // By default fs.readFile is used
30 },
31 (err, result) => {
32 // err: Error?
33 // result.result: [Buffer | String, SourceMap?, Meta?]
34 // The result as an array matching the arguments passed by the final normal loader
35 // (typically [content, sourceMap, meta])
36 // only available when no error occurred
37 // result.resourceBuffer: Buffer
38 // The raw resource as Buffer (useful for SourceMaps)
39 // only available when no error occurred
40 // result.cacheable: Bool
41 // Is the result cacheable or do it require reexecution?
42 // result.fileDependencies: String[]
43 // An array of paths (existing files) on which the result depends on
44 // result.missingDependencies: String[]
45 // An array of paths (not existing files) on which the result depends on
46 // result.contextDependencies: String[]
47 // An array of paths (directories) on which the result depends on
48 }
49);
50```
51
52More documentation following...
Note: See TracBrowser for help on using the repository browser.