Created
January 10, 2018 09:51
-
-
Save markusbergh/aae07f8720ea8da5a4b2ae526ea2280b to your computer and use it in GitHub Desktop.
Highlight.js with tree shaking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Core import | |
import highlightjs from 'highlight.js/lib/highlight' | |
// Languages import | |
import javascript from 'highlight.js/lib/languages/javascript' | |
import bash from 'highlight.js/lib/languages/bash' | |
import yaml from 'highlight.js/lib/languages/yaml' | |
// Register languages | |
highlightjs.registerLanguage('javascript', javascript) | |
highlightjs.registerLanguage('bash', bash) | |
highlightjs.registerLanguage('yaml', yaml) | |
... |
Change this to and it will work:
import hljs from 'highlight.js/lib/core'; import typescript from 'highlight.js/lib/languages/typescript'; import 'highlight.js/styles/github.css'; hljs.registerLanguage('typescript', typescript);
Only change is changing
import highlightjs from 'highlight.js/lib/highlight'
=>import hljs from 'highlight.js/lib/core';
Beautiful! This worked wonders!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Change this to and it will work:
Only change is changing
import highlightjs from 'highlight.js/lib/highlight'
=>import hljs from 'highlight.js/lib/core';