Skip to content

ivelum/relay-compiler-webpack-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Relay Compiler Webpack Plugin

npm version Build Status

Are you running Relay Modern? Are you annoyed with constantly running the relay-compiler to generate code, especially if you're already running Webpack?

Well be annoyed no more! Simply install this plugin to automatically hook into Webpack's build process to generate these files for you.

Installation

  1. Add this to your project:
  yarn add --dev relay-compiler-webpack-plugin
  # Or if you're using npm
  npm install --save-dev relay-compiler-webpack-plugin
  1. Add the plugin to your Webpack configuration:
const RelayCompilerWebpackPlugin = require('relay-compiler-webpack-plugin')
const path = require('path')

module.exports = {
  // ... Your existing Webpack configuration
  plugins: [
    // ...
    new RelayCompilerWebpackPlugin({
      schema: path.resolve(__dirname, './relative/path/to/schema.graphql'), // or schema.json or a GraphQLSchema instance
      src: path.resolve(__dirname, './relative/path/to/source/files'),
    })
  ]
  // ...
}
  1. 🎉

Gotchas

If there are multiple versions of GraphQL in your dependency tree it will cause schema validation errors. To get around this, ensure you have the same graphql version as your relay-compiler version depends on. To assist this you can install dependencies as flat which ensures only one version of each dependency.

Example Project

To see an example of its usage within a project, see relay-compiler-webpack-plugin-example.

Development

Running tests:

yarn test

Running tests with coverage:

yarn test:coverage

License

Relay Compiler Webpack Plugin may be redistributed according to the BSD 3-Clause License.

Copyright 2019

About

Automatically run the Relay Compiler from Webpack

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%