A babel plugin to use PrismJS with standard bundlers.
npm install babel-plugin-prismjsA babel plugin to use PrismJS with standard bundlers.
In your code, import prismjs:
``js
import Prism from 'prismjs';
Prism.highlightAll();
`
The exported Prism object will be the fully-configured Prism instance.
- You must be using ES6 imports to load PrismJS.
In your .babelrc, register the plugin and configure its dependencies:
`json`
{
"plugins": [
["prismjs", {
"languages": ["javascript", "css", "markup"],
"plugins": ["line-numbers"],
"theme": "twilight",
"css": true
}]
]
}
Each key are used as follows:
* languages: Array of languages to include in the bundle or "all" to include all languages. Those languages can be found here.plugins
* : Array of plugins to include in the bundle. Those plugins can be found here.theme
* : Name of theme to include in the bundle. Themes can be found here.css
* : Boolean indicating whether to include .css files in the result. Defaults to false. If true, imports will be added for .css files. Must be true in order for theme` to work.