codesandbox/sandpack

Is it possible to load local files

Closed this issue · 2 comments

Tell us how you think we can improve Sandpack

Packages affected

  • sandpack-client
  • sandpack-react

What is this feature?

I noticed that there is a customSetup configuration property,Is it possible to configure a local file and then load the code of the local file?

I have an index.mdx file, and then there is index.js at the same level.

// index.mdx
import { Sandpack } from '@codesandbox/sandpack-react'

## substring


<Sandpack
  template='vanilla'
  customSetup={{
    entry: './index.js'
  }}
/>
// index.js
const s = '0011'

console.log(s.substring(0, 1))

Thank you very much

Hey! It's not possible. Sandpack can't access the local file system of your computer, but you could Node.js fs or something to pass it the Sandpack

Thank you very much, you made it very clear