Skip to content

Instantly share code, notes, and snippets.

@kuon
Created January 5, 2017 05:51
Show Gist options
  • Save kuon/69366b9d448406a7b79e488c83f76fb4 to your computer and use it in GitHub Desktop.
Save kuon/69366b9d448406a7b79e488c83f76fb4 to your computer and use it in GitHub Desktop.
brunch multiple compilers
diff --git a/lib/watch.js b/lib/watch.js
index 4140528..9421446 100644
--- a/lib/watch.js
+++ b/lib/watch.js
@@ -316,9 +316,34 @@ class BrunchWatcher {
this.fileList.emit('change', path, compiler, [], isHelper);
} else {
const isFor = plugin => plugin.pattern.test(path);
- const compiler = this.plugins.compilers.filter(isFor);
const currentLinters = this.plugins.linters.filter(isFor);
- this.fileList.emit('change', path, compiler, currentLinters, isHelper);
+ const compiler = this.plugins.compilers.filter(isFor);
+
+ const additionalCompilers = [];
+
+ // Check if compilers need to be chained, chain up to 10 compilers
+ for (let i = 0; i < 10; i++) {
+ let additionalCompiler = null;
+
+ compiler.forEach(compiler => {
+ if (compiler.compiledExtension) {
+ const compiledPath = path + '.' + compiler.compiledExtension;
+ additionalCompiler = this.plugins.compilers.find(plugin => {
+ return additionalCompilers.indexOf(plugin) === -1 &&
+ plugin.pattern.test(compiledPath);
+ });
+ }
+ });
+
+ if (!additionalCompiler) {
+ break;
+ }
+ additionalCompilers.push(additionalCompiler);
+ }
+
+
+ this.fileList.emit('change', path, compiler.concat(additionalCompilers),
+ currentLinters, isHelper);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment