Can I import everything from a javascript library with parcelJS?

182 Views Asked by At

I recently started using parcelJS to build and I'm pretty new to Webpack and such tools. I use the highlighJS library to highlight some syntax on my page and I'm importing it using the line below.

import hljs from 'highlight.js/lib/highlight';

This library also has languages that to highlight the syntax which can be imported using:

import python from 'highlight.js/lib/languages/python';

Is there a way to import all of the languages in the folder instead of importing them one by one?

1

There are 1 best solutions below

0
On

Using import hljs from 'highlight.js' imports all the languages and functions in highlightJS when using hljs.highlightBlock(vnode.dom); syntax is automatically detected and highlighted and there is no need to register a language.