An open API service indexing awesome lists of open source software.

https://github.com/dominictobias/babel-plugin-source-code

A babel plugin which allows you to render Prism syntax highlighted code snippets of files with 0 runtime cost
https://github.com/dominictobias/babel-plugin-source-code

Last synced: 27 days ago
JSON representation

A babel plugin which allows you to render Prism syntax highlighted code snippets of files with 0 runtime cost

Awesome Lists containing this project

README

        

# babel-plugin-source-code

Import file contents into your JSX `` blocks at build time. Great for syntax highlighting component examples.

# Installation

Install [Prism](https://github.com/PrismJS/prism/) as per their guide.

Install `yarn add -D babel-plugin-source-code` or `npm i -D babel-plugin-source-code`.

Add it to your babel plugins config:

```json
{
"plugins": ["babel-plugin-source-code"]
}
```

# Usage

Create your demos in separate files to the documentation:

```tsx
import { ButtonDemo } from './ButtonDemo'

export default function ButtonDocs() {
return (








)
}
```

Only use relative paths in `data-path`.