Gatsby: Allow custom file extensions

Created on 30 Jan 2017  Â·  4Comments  Â·  Source: gatsbyjs/gatsby

Howdy!

I don't necessarily think it would be a good idea to actually accept this, but I thought I should raise it, especially since I will probably move the LightScript Docs off of Gatsby due to this (I may use a fork instead, and I've been very impressed with Gatsby, fwiw).

It would be nice to allow custom file extensions. In my case, LightScript has the extensions .lsc and .lsx.

I was able to support this in my case by modifying the node_modules/gatsby/dist dir locally (not exactly sustainable/production-friendly) by adding lsc and lsx wherever cjsx appeared in the codebase, and by adding the following to my gatsby-node.js:

exports.modifyWebpackConfig = function(config, stage) {
  const jsBabelQuery = config._loaders.js.config.query;
  config.loader('lsc', {
    test: /\.lsc|\.lsx/,
    exclude: /(node_modules)/,
    loader: 'babel',
    query: jsBabelQuery,
  });

  const origResolver = config.resolve;
  config.resolve = function lightscriptResolve() {
    const result = origResolver.call(this, arguments);
    result.resolve.extensions.push('.lsc', '.lsx');
    return result;
  }

  return config;
}

The locations where I needed to modify the package:

Again, I don't predict it'll be worth your while to support this. I can just fork this for now, or move off Gatsby, since I'm not using most of its power anyway.

Cheers!
Alex

Most helpful comment

That'd be fun! You're in SF right? Send me a DM and we could meetup
sometime.

On Tue, Jan 31, 2017 at 10:55 AM Alex Rattray notifications@github.com
wrote:

Wow awesome! Thanks @KyleAMatthews ! Would love your input on the language
one of these days if you're interested btw!

—
You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/653#issuecomment-276456232,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEVh09OeLZemjywfx41ul7CdGNtI03Nks5rX4OTgaJpZM4LxD0H
.

All 4 comments

I created the fork, you can see it here: https://github.com/lightscript/gatsby/tree/lightscript

I recommend closing this issue 😄

Yeah, I'd love to be able to support JS alternatives like LightScript but Gatsby 0.x being a monolith means we'd have to ship support for LightScript to everyone...

1.0 will make it really easy to create a gatsby-plugin-lightscript for drop-in support! Would love to help you get that going once plugin support lands (very soon).

Wow awesome! Thanks @KyleAMathews ! Would love your input on the language one of these days if you're interested btw

That'd be fun! You're in SF right? Send me a DM and we could meetup
sometime.

On Tue, Jan 31, 2017 at 10:55 AM Alex Rattray notifications@github.com
wrote:

Wow awesome! Thanks @KyleAMatthews ! Would love your input on the language
one of these days if you're interested btw!

—
You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/653#issuecomment-276456232,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEVh09OeLZemjywfx41ul7CdGNtI03Nks5rX4OTgaJpZM4LxD0H
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rossPatton picture rossPatton  Â·  3Comments

Oppenheimer1 picture Oppenheimer1  Â·  3Comments

magicly picture magicly  Â·  3Comments

ferMartz picture ferMartz  Â·  3Comments

ghost picture ghost  Â·  3Comments