Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WebpackRelayCompilerPlugin
const childProcess = require('child_process');
function RelayCompilerPlugin(options) {
this.schema = options.schema;
this.src = options.src;
}
RelayCompilerPlugin.prototype.apply = function(compiler) {
const cmd = `relay-compiler --src ${this.src} --schema ${this.schema}`;
compiler.plugin('after-compile', (compilation, callback) => {
compilation.fileDependencies.add(this.schema);
callback();
});
compiler.plugin('before-compile', () => {
console.log(`RelayCompilerPlugin: ${cmd}`);
childProcess.execSync(cmd,
{
stdio: [0, 1, 2],
},
);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.