Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation on preLoaders and postLoaders #19

Closed
jhnns opened this issue Aug 17, 2012 · 7 comments
Closed

Add documentation on preLoaders and postLoaders #19

jhnns opened this issue Aug 17, 2012 · 7 comments

Comments

@jhnns
Copy link
Member

jhnns commented Aug 17, 2012

In the last issue you pointed out to use a postLoader like this:

module.exports = function(source) {
   // do something
  return source;
}

Is the signature of pre- and postLoaders documented anywhere?

@sokra
Copy link
Member

sokra commented Aug 22, 2012

pre and post loaders are loaders ;)

wiki Loader-Specification

usage options

@jhnns
Copy link
Member Author

jhnns commented Sep 7, 2012

But usually a loader isn't called with the source, is it?

@sokra
Copy link
Member

sokra commented Sep 8, 2012

It is. It's called with the content of the file which it should "load". Take a look at some of my loaders to see examples.

@sokra
Copy link
Member

sokra commented Sep 9, 2012

You can imagine loaders as some kind of transformation applied to the file content before including it in the bundle.

require("loaderA!loaderB!./file.txt");

// while compiling: (simplified)
var loaderA = require("loaderA");
var loaderB = require("loaderB");
addToBundle(loaderA(loaderB(readFile("./file.txt"))));

pre/post loaders work the same but you just don't specify them in the require call.

@jhnns
Copy link
Member Author

jhnns commented Sep 10, 2012

Ah ok. So I don't have to use fs.readFile within a loader.

@sokra
Copy link
Member

sokra commented Sep 10, 2012

No, you can and should use the parameter. Elsewise chaining of loader will not work correctly.

@jhnns
Copy link
Member Author

jhnns commented Sep 18, 2012

Oops. I will adjust that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants