-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Allow for multiple preprocessors to be chained #161
Comments
Reopening the issue, I had to revert this commit as it breaks the preprocessing functionality. Otherwise I totally agree, we want to allow multiple preprocessors, I will get back to this. Preprocessors can change the file name as well (eg. coffee, html2js do that). It might be desired to apply a preprocessor based on this renaming as well. Need to think about it though... |
With preprocessors are you not starting to step into the arena of build tools? Would it not be better to somehow create a better integration with one or more build tools so that one didn't need to set up multiple tools to do build and testing? |
Great idea. What about the possibillty to inject your gruntfile and have it executed before files are served. |
Interesting idea, +1 for researching integration with grunt. I used to use grunt watch for compiling coffee script, before adding preprocessors into Testacular. I had two issues:
|
|
I've started a new discussion about only compiling changed files in gruntjs/grunt-contrib-watch#14. It seems that it hasn't been solved yet. |
I had another idea, if we rewrite the webserver using connect, we could add the ability to include arbitrary connect middleware to handle files before they get served. That might be much more efficient as these middlewares are already built for this purpose. |
Rewriting the web server with connect is for sure. Using a middleware for this is an interesting idea, but I'm afraid it still needs to be coupled to the watcher/fileList, because it needs to be preprocessed when the file changes. Web server does not have this information. |
Actually it does. I've looked at some of connects asset compile middleware On Monday, December 10, 2012, Vojta Jina wrote:
|
Just forwarding @dignifiedquire 's comment from #334 I've been thinking about how to handle multiple preprocessors. Short example var fs = require('fs');
var es = require('event-stream');
// this is an array of all preprocessors that we want to execute
// this need to be "pipeable"
var preprocessors = createPreprocessors(filename, config.preprocessors);
var file = fs.createReadStream(filename, {flags: 'r'});
// pipe all the things
var result = es.pipeline.apply(this, [fileStream].concat(preprocessors)); Update Use event-stream. |
I propose a change to the config file - remove the files = [
'lib/jquery.js',
{pattern: 'src/*.coffee', preprocess: ['coffee', ...]},
'test/*.js'
]; No reason to specify the matching patterns multiple times. Explicit order of preprocessors. |
I'm afraid I don't think this will improve anything. For example if you have written everything in CoffeeScript, right now you can specify to preprocess all // Old
files = [
'src/*.coffee',
'test/unit/*.coffee'
];
preprocessors = {
'**/*.coffee': 'coffee'
}
// New
files = [
{pattern: 'src/*.coffee', preprocess: ['coffee']},
{pattern: 'test/unit/*.coffee', preproces: ['coffee']}
]; If you have a large list of files this can get quickly out of hand in my opinion. |
That's a good point. |
Mutiple preprocessors is already done, so I'm closing this issue. There were some other interesting points in this discussion that I will keep in mind (esp. changing preprocessors to work with streams is neat and will happen; hopefully ;-)) |
How are multiple preprocessors implemented now? |
You can chain multiple preprocessors like this:
Please feel free to send a PR with imrpoving the docs... |
When I chan multiple preprocessors like so:
I get:
|
@bekite sorry, I forgot this is only in 0.9 (which is not stable release yet). |
As discussed before we need the ability to chain preprocessors. I suggest the following api.
This would allow you to specify an array of preprocessors in exactly the order you want them to be executed or if you just define one, only this one will be executed.
Gonna implement this later this day if I find the time.
The text was updated successfully, but these errors were encountered: