-
-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No Syntax highlighting when built #196
Comments
So to build on this I have tried switching it from hljs to prism and that highlights it fine |
since it works in the dev environment i am guessing it is webpack config there, please ask on stackoverflow or in the CRA issues |
for anyone else running into this, leaving out |
Oh boy, I just spent a couple of hours debugging what was essentially this exact same problem. 😳 I made progress and I think I have answers for anyone who stumbles on this in the future. I'm using NextJS with static exports and Here are my findings:
import { Light as SyntaxHighlighter } from 'react-syntax-highlighter';
import xml from 'react-syntax-highlighter/dist/cjs/languages/hljs/xml';
import javascript from 'react-syntax-highlighter/dist/cjs/languages/hljs/javascript';
SyntaxHighlighter.registerLanguage('xml', xml);
SyntaxHighlighter.registerLanguage('javascript', javascript);
There was one unexplained portion for me, which is that for what looked like a single animation frame, my code did seem to render with proper syntax highlighting even in production (although it used the wrong theme). Afterward, it would revert to what's shown in the original post's images (where there's a |
Perfect explanation @Adam13531, thanks for sharing how you solved the problem |
Describe the bug
Currently when I am working in my dev environment and the syntax highlighting is working as expected, however when I build the app there is no syntax highlighting and it just renders the string that was passed in (using CRA btw)
To Reproduce
The repo can be found here:
https://github.com/Adam-Collier/rownan-react/tree/build_app
you can try it in dev
npm run dev
and build
npm run build && npm run electron
Expected behavior
I expected the syntax highlighting to be identical to that in development
Screenshots
Before it is built:
After it is built:
what is in the inspector:
Desktop (please complete the following information):
I have no idea why it would do this, hope this can be solved
The text was updated successfully, but these errors were encountered: