Babel transpile JSX to JS - Handling for different file extensions
See original GitHub issueI use Babel CLI for production to compile my ES6 code to ES5. The files with the extension .jsx
be compiled to .js
. The server will only recognize the .jsx
ending. How do you solve the problem?
server.views({
engines: {
jsx: HapiReactViews,
},
compileOptions: {
doctype: '',
},
relativeTo: __dirname,
path: 'views',
});
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Compile .jsx files instead of .js using babel - Stack Overflow
It will run babel loader on the .jsx files, instead of .js files. If you want to transpile both .js and .jsx ,...
Read more >babel/plugin-transform-react-jsx
Automatic runtime is a feature added in v7.9.0 . With this runtime enabled, the functions that JSX compiles to will be imported automatically....
Read more >Using jsx in .jsx files not achievable -- Babel presets aren't used
.jsx files' jsx code should be transpiled according to the tsconfig's jsx option or there should be another way to achieve this.
Read more >Three ways to use Babel with React - JavaScript in Plain English
1: Transpile JSX syntax using react preset. 2: Transpile template literal using template ... 3: let babel-loader to handle JavaScript files.
Read more >Build a Modern JS Project - #6 Babel & React - YouTube
In this video, we'll enable transpilation of ES6+ and JSX syntax in our project. We'll start by configuring ESLint rules for React via ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ThiagoMiranda Nice to hear that it works. 👍
@danielbayerlein Sorry to bother you in this issue but I’m experiencing the same issue here and when I add
js: HapiReactViews
in my engines configuration object I got an error:Unknown extension and no defaultExtension configured for view template: Default
( my original file is name Default.jsx ).In my view route I just put
reply.view('Default')
so do I have to write an extension? If so, how did you deal with it? Using a env argument? ThanksUpdate: solved it with the
defaultExtension
option on the server.views