jedireza / hapi-react-views

:package: A hapi view engine for React components
MIT License
231 stars 33 forks source link

can't use jsx file when build ahead of time #79

Closed empeje closed 5 years ago

jedireza commented 5 years ago

Please add some more detail of the issue you're experiencing and provide a minimal code example demonstrating what what's not working.

empeje commented 5 years ago

I use your template @jedireza in the example folder.

I found that using babel when we precompiled the asset, it uses js extension while in development using babel-node I can use jsx.

So I endup using this code for workaround

  await hapi.views({
    engines: {
      [FAMEWEKA_ENV === 'production' ? 'js' : 'jsx']: HapiReactViews
    },
    relativeTo: __dirname,
    path: 'views',
    compileOptions: {
      renderMethod: 'renderToString',
      layoutPath: path.join(__dirname, 'views'),
      layout: 'BaseLayout'
    }
  });
jedireza commented 5 years ago

Nice. Thanks for sharing your learnings Configuring the view engine with the extensions it needs to be compatible with makes sense.