Adds CoffeeScript support for Gatsby
npm install gatsby-plugin-coffeescriptProvides drop-in support for CoffeeScript and CJSX.
npm install gatsby-plugin-coffeescript
1. Include the plugin in your gatsby-config.js file.
2. Write your components in CJSX or CoffeeScript.
``javascriptgatsby-plugin-coffeescript
// in gatsby-config.js
plugins: [
// no configuration
,gatsby-plugin-coffeescript
// custom configuration
{
resolve: ,`
// options are passed directly to the compiler
options: {},
},
]
First, note that CoffeeScript + React is a troubled combination. This plugin
relies upon deprecated modules that may someday prove to be dysfunctional or
otherwise deficient.
Furthermore, note that the installed version of CoffeeScript is @next. This is
not optional - _named exports are required for page queries to work properly._
You will need to manually edit your coffee-loader installation and installcoffeescript separately in your project directory to ensure thatindex.js
CoffeeScript@next is being loaded. The very first line of source in the former's should be the following: note the lack of dash.
`js``
var coffee = require("coffeescript")