You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

4 years ago
  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...