fea0ed5d46e731212da686e72b66d3fcd0573e4923e80ee8adcfd7f4cec77261d75ec25ec2df579da03f0fe0efac5ba9f818bf39ff880b2f3fa847318ac593 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # loader-runner
  2. ``` js
  3. import { runLoaders } from "loader-runner";
  4. runLoaders({
  5. resource: "/abs/path/to/file.txt?query",
  6. // String: Absolute path to the resource (optionally including query string)
  7. loaders: ["/abs/path/to/loader.js?query"],
  8. // String[]: Absolute paths to the loaders (optionally including query string)
  9. // {loader, options}[]: Absolute paths to the loaders with options object
  10. context: { minimize: true },
  11. // Additional loader context which is used as base context
  12. readResource: fs.readFile.bind(fs)
  13. // A function to read the resource
  14. // Must have signature function(path, function(err, buffer))
  15. }, function(err, result) {
  16. // err: Error?
  17. // result.result: Buffer | String
  18. // The result
  19. // result.resourceBuffer: Buffer
  20. // The raw resource as Buffer (useful for SourceMaps)
  21. // result.cacheable: Bool
  22. // Is the result cacheable or do it require reexecution?
  23. // result.fileDependencies: String[]
  24. // An array of paths (files) on which the result depends on
  25. // result.contextDependencies: String[]
  26. // An array of paths (directories) on which the result depends on
  27. })
  28. ```
  29. More documentation following...